#--------------------------------------------------- # SimTK CPODES # # Creates SimTK Core library, base name=SimTKcpodes. # Default libraries are shared & optimized. Variants # are created for static (_static) and debug (_d). # # Windows: # [ns_]SimTKcpodes[_d].dll # [ns_]SimTKcpodes[_d].lib # [ns_]SimTKcpodes_static[_d].lib # Unix: # lib[ns_]SimTKcpodes[_d].so # lib[ns_]SimTKcpodes_static[_d].a # # All libraries are installed in # %ProgramFiles%\SimTK\lib[64] (Windows) # /usr/local/SimTK/lib[64] (UNIX) # #---------------------------------------------------- cmake_minimum_required(VERSION 2.4.6) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) cmake_policy(SET CMP0005 NEW) endif(COMMAND cmake_policy) PROJECT (SimTKcpodes) # Use this to generate a private set of libraries whose names # won't conflict with installed versions. SET(BUILD_USING_NAMESPACE "" CACHE STRING "All library names will be prefixed with 'xxx_' if this is set to xxx.") SET(NS) IF(BUILD_USING_NAMESPACE) SET(NS "${BUILD_USING_NAMESPACE}_") ENDIF(BUILD_USING_NAMESPACE) SUBDIRS (staticTarget sharedTarget sundials tests) # # Make sure "sandbox" input & output directories are set. During # SimTK Core build, the build system will set them. Otherwise, we'll # set them to sensible local values. # If SimTK_INSTALL_PREFIX is set then # it is a sandbox installation area, otherwise we want to install # in /usr/local/SimTK or %ProgramFiles%\SimTK. Similarly, SimTK_SDK # tells us where to find other SimTK Core modules on which this one # depends. If it is not set, we'll look in /usr/local/SimTK or # %ProgramFiles%\SimTK *regardless* of SimTK_INSTALL_PREFIX. # IF(${CMAKE_C_COMPILER} MATCHES "gcc") IF(NOT SimTK_INSTALL_PREFIX) SET(SimTK_INSTALL_PREFIX "/usr/local/SimTK" CACHE PATH "Install directory") ENDIF(NOT SimTK_INSTALL_PREFIX) IF(NOT SimTK_SDK) SET(SimTK_SDK "/usr/local/SimTK" CACHE PATH "SimTK dependency path" ) ENDIF(NOT SimTK_SDK) ELSE(${CMAKE_C_COMPILER} MATCHES "gcc") IF(NOT SimTK_INSTALL_PREFIX) SET(SimTK_INSTALL_PREFIX "$ENV{ProgramFiles}/SimTK" CACHE PATH "Install directory") ENDIF(NOT SimTK_INSTALL_PREFIX) IF(NOT SimTK_SDK) SET(SimTK_SDK "$ENV{ProgramFiles}/SimTK" CACHE PATH "SimTK dependency path") ENDIF(NOT SimTK_SDK) ENDIF(${CMAKE_C_COMPILER} MATCHES "gcc") MARK_AS_ADVANCED( SimTK_SDK ) MARK_AS_ADVANCED( SimTK_INSTALL_PREFIX ) INCLUDE_DIRECTORIES(${SimTK_SDK}/include) # The build system will set ARCH64 for 64 bit builds, which require # use of the lib64/ library directories rather than lib/. #SET( ARCH64 ON CACHE BOOL "ON for 64bit builds, OFF for 32bit builds") #MARK_AS_ADVANCED( ARCH64 ) #IF (ARCH64) # SET(LIB64 64) #ELSE (ARCH64) # SET(LIB64) # nothing #ENDIF (ARCH64) IF( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 ) SET( LIB64 64 ) ELSE( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 ) SET( LIB64 ) ENDIF( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 ) # Allow build of binaries on Leopard that work on Tiger IF( APPLE ) SET( CMAKE_CXX_FLAGS "-mmacosx-version-min=10.4" ) SET( CMAKE_C_FLAGS "-mmacosx-version-min=10.4" ) ENDIF( APPLE ) IF(UNIX AND NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Debug or Release build" FORCE) ENDIF (UNIX AND NOT CMAKE_BUILD_TYPE) ## Choose the maximum level of x86 instruction set that the compiler is ## allowed to use. SSE2 is ubiquitous enough now that we don't mind ## abandoning machines that can't handle those instructions. SSE3 migh ## also be reasonable by now (April 2009) so this default should be ## revisited soon. This can be set to a different value by the person ## running CMake. SET(BUILD_INST_SET "sse2" # use SSE2 instruction set by default CACHE STRING "CPU instruction level compiler is permitted to use.") MARK_AS_ADVANCED( BUILD_INST_SET ) ## When building in any of the Release modes, tell gcc to use full optimization and ## to generate SSE2 floating point instructions. Here we are specifying *all* of the ## Release flags, overriding CMake's defaults. IF(${CMAKE_C_COMPILER} MATCHES "gcc") STRING(TOLOWER ${BUILD_INST_SET} GCC_INST_SET) # C++ SET(CMAKE_CXX_FLAGS_DEBUG "-g -m${GCC_INST_SET}" CACHE STRING "g++ Debug build compile flags" FORCE) SET(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -m${GCC_INST_SET}" CACHE STRING "g++ Release build compile flags" FORCE) SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O3 -g -m${GCC_INST_SET}" CACHE STRING "g++ RelWithDebInfo build compile flags" FORCE) SET(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os -m${GCC_INST_SET}" CACHE STRING "g++ MinSizeRel build compile flags" FORCE) # C SET(CMAKE_C_FLAGS_DEBUG "-g -m${GCC_INST_SET}" CACHE STRING "gcc Debug build compile flags" FORCE) SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3 -m${GCC_INST_SET}" CACHE STRING "gcc Release build compile flags" FORCE) SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-DNDEBUG -O3 -g -m${GCC_INST_SET}" CACHE STRING "gcc RelWithDebInfo build compile flags" FORCE) SET(CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os -m${GCC_INST_SET}" CACHE STRING "gcc MinSizeRel build compile flags" FORCE) ENDIF(${CMAKE_C_COMPILER} MATCHES "gcc") ## When building in any of the Release modes, tell VC++ cl compiler to use intrinsics ## (i.e. sqrt instruction rather than sqrt subroutine) with flag /Oi. IF(${CMAKE_C_COMPILER} MATCHES "cl") STRING(TOUPPER ${BUILD_INST_SET} CL_INST_SET) ## C++ SET(CMAKE_CXX_FLAGS_DEBUG "/D _DEBUG /MDd /Od /Ob0 /RTC1 /Zi /arch:${CL_INST_SET}" CACHE STRING "VC++ Debug build compile flags" FORCE) SET(CMAKE_CXX_FLAGS_RELEASE "/D NDEBUG /MD /O2 /Ob2 /Oi /arch:${CL_INST_SET}" CACHE STRING "VC++ Release build compile flags" FORCE) SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/D NDEBUG /MD /O2 /Ob2 /Oi /Zi /arch:${CL_INST_SET}" CACHE STRING "VC++ RelWithDebInfo build compile flags" FORCE) SET(CMAKE_CXX_FLAGS_MINSIZEREL "/D NDEBUG /MD /O1 /Ob1 /Oi /arch:${CL_INST_SET}" CACHE STRING "VC++ MinSizeRel build compile flags" FORCE) ## C SET(CMAKE_C_FLAGS_DEBUG "/D _DEBUG /MDd /Od /Ob0 /RTC1 /Zi /arch:${CL_INST_SET}" CACHE STRING "VC++ Debug build compile flags" FORCE) SET(CMAKE_C_FLAGS_RELEASE "/D NDEBUG /MD /O2 /Ob2 /Oi /arch:${CL_INST_SET}" CACHE STRING "VC++ Release build compile flags" FORCE) SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/D NDEBUG /MD /O2 /Ob2 /Oi /Zi /arch:${CL_INST_SET}" CACHE STRING "VC++ RelWithDebInfo build compile flags" FORCE) SET(CMAKE_C_FLAGS_MINSIZEREL "/D NDEBUG /MD /O1 /Ob1 /Oi /arch:${CL_INST_SET}" CACHE STRING "VC++ MinSizeRel build compile flags" FORCE) ENDIF(${CMAKE_C_COMPILER} MATCHES "cl") # The source is organized into subdirectories, but we handle them all from # this CMakeLists file rather than letting CMake visit them as SUBDIRS. SET(CPODES_SOURCE_SUBDIRS sundials .) SET(CPODES_LIBRARY_NAME ${NS}SimTKcpodes CACHE STRING "Base name of the library being built; can't be changed here; see BUILD_USING_NAMESPACE variable." FORCE) # Collect up information about the version of the SimTKcpodes library we're building # and make it available to the code so it can be built into the binaries. SET(CPODES_MAJOR_VERSION 1) SET(CPODES_MINOR_VERSION 6) SET(CPODES_BUILD_VERSION 0) SET(CPODES_COPYRIGHT_YEARS "2005-6") # underbar separated list of authors, no spaces SET(CPODES_AUTHORS "Regents.of.UC_Radu.Serban_Michael.Sherman") # Get the subversion revision number if we can # It's possible that WIN32 installs use svnversion through cygwin # so we'll try for both svnversion.exe and svnversion. Note that # this will result in warnings if all you have is Tortoise without # Cygwin, and your "about" string will say "unknown" rather than # providing the SVN version of the source. FIND_PROGRAM (SVNVERSION_EXE svnversion.exe) IF (SVNVERSION_EXE) EXEC_PROGRAM (${SVNVERSION_EXE} ARGS "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE CPODES_SVN_REVISION ) ELSE (SVNVERSION_EXE) FIND_PROGRAM (SVNVERSION svnversion) IF (SVNVERSION) EXEC_PROGRAM (${SVNVERSION} ARGS "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE CPODES_SVN_REVISION) ELSE (SVNVERSION) MESSAGE (STATUS "Could not find 'svnversion' executable; 'about' will be wrong. (Cygwin provides one on Windows.)" ) SET (CPODES_SVN_REVISION unknown) ENDIF (SVNVERSION) ENDIF (SVNVERSION_EXE) # Remove colon from build version, for easier placement in directory names STRING(REPLACE ":" "_" CPODES_SVN_REVISION ${CPODES_SVN_REVISION}) ADD_DEFINITIONS(-DSimTK_CPODES_LIBRARY_NAME=${CPODES_LIBRARY_NAME} -DSimTK_CPODES_MAJOR_VERSION=${CPODES_MAJOR_VERSION} -DSimTK_CPODES_MINOR_VERSION=${CPODES_MINOR_VERSION} -DSimTK_CPODES_BUILD_VERSION=${CPODES_BUILD_VERSION}) # CMake quotes automatically when building Visual Studio projects but we need # to add them ourselves for Linux or Cygwin. Two cases to avoid duplicate quotes # in Visual Studio which end up in the binary. IF (${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(NEED_QUOTES FALSE) ELSE (${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(NEED_QUOTES TRUE) ENDIF (${CMAKE_GENERATOR} MATCHES "Visual Studio") ##TODO: doesn't work without quotes in nightly build SET(NEED_QUOTES TRUE) IF(NEED_QUOTES) ADD_DEFINITIONS(-DSimTK_CPODES_SVN_REVISION="${CPODES_SVN_REVISION}" -DSimTK_CPODES_COPYRIGHT_YEARS="${CPODES_COPYRIGHT_YEARS}" -DSimTK_CPODES_AUTHORS="${CPODES_AUTHORS}") ELSE(NEED_QUOTES) ADD_DEFINITIONS(-DSimTK_CPODES_SVN_REVISION=${CPODES_SVN_REVISION} -DSimTK_CPODES_COPYRIGHT_YEARS=${CPODES_COPYRIGHT_YEARS} -DSimTK_CPODES_AUTHORS=${CPODES_AUTHORS}) ENDIF(NEED_QUOTES) # -DSimTK_CPODES_TYPE has to be defined in the target subdirectories. # -DSimTKcpodes_EXPORTS defined automatically when Windows DLL build is being done. # Report the version number to the CMake UI SET(CPODES_VERSION "${CPODES_MAJOR_VERSION}.${CPODES_MINOR_VERSION}.${CPODES_BUILD_VERSION}" CACHE STRING "This is the version of SimTK CPODES which will be built." FORCE) SET(SHARED_TARGET ${CPODES_LIBRARY_NAME}) SET(STATIC_TARGET ${CPODES_LIBRARY_NAME}_static) ## If no one says otherwise, change the executable path to drop into the same binary ## location as the DLLs so that the test cases will use the just-build DLLs. IF(NOT EXECUTABLE_OUTPUT_PATH) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR} CACHE INTERNAL "Single output directory for building all executables.") ENDIF(NOT EXECUTABLE_OUTPUT_PATH) IF(NOT LIBRARY_OUTPUT_PATH) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR} CACHE INTERNAL "Single output directory for building all libraries.") ENDIF(NOT LIBRARY_OUTPUT_PATH) SET(${PROJECT_NAME}_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}) SET(${PROJECT_NAME}_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}) # Ensure that debug libraries have "_d" appended to their names. # CMake gets this right on Windows automatically with this definition. IF (${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_DEBUG_POSTFIX "_d" CACHE INTERNAL "" FORCE) ENDIF (${CMAKE_GENERATOR} MATCHES "Visual Studio") # But on Unix or Cygwin we have to add the suffix manually IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug) SET(SHARED_TARGET ${SHARED_TARGET}_d) SET(STATIC_TARGET ${STATIC_TARGET}_d) ENDIF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug) SET(SimTKCOMMON_LIBRARY_NAME ${NS}SimTKcommon) SET(SimTKCOMMON_SHARED_LIBRARY ${SimTKCOMMON_LIBRARY_NAME}) SET(SimTKCOMMON_STATIC_LIBRARY ${SimTKCOMMON_LIBRARY_NAME}_static) # Find the right place to look for dependency resolution (which # can be the default install directory or specified SimTK_SDK directory). # # Also, determine which math libraries to use for this platform. # IF(${CMAKE_C_COMPILER} MATCHES "gcc") ## A gcc build SET(MATH_LIBS_TO_USE SimTKlapack pthread) ELSE(${CMAKE_C_COMPILER} MATCHES "gcc") ## Assume Microsoft Visual Studio SET(MATH_LIBS_TO_USE SimTKlapack pthreadVC2) ENDIF(${CMAKE_C_COMPILER} MATCHES "gcc") # These are all the places to search for header files which are # to be part of the API. SET(API_INCLUDE_DIRS ./include ./include/SimTKcpodes ./include/SimTKcpodes/internal sundials/include/cpodes sundials/include/cvodes sundials/include/ida sundials/include/kinsol sundials/include/nvector sundials/include/sundials) # We'll need both *relative* path names, starting with their API_INCLUDE_DIRS, # and absolute pathnames. SET(API_REL_INCLUDE_FILES) # start these out empty SET(API_ABS_INCLUDE_FILES) FOREACH(dir ${API_INCLUDE_DIRS}) FILE(GLOB fullpaths ${dir}/*.h) # returns full pathnames SET(API_ABS_INCLUDE_FILES ${API_ABS_INCLUDE_FILES} ${fullpaths}) FOREACH(pathname ${fullpaths}) GET_FILENAME_COMPONENT(filename ${pathname} NAME) SET(API_REL_INCLUDE_FILES ${API_REL_INCLUDE_FILES} ${dir}/${filename}) ENDFOREACH(pathname) ENDFOREACH(dir) # collect up source files FILE(GLOB SOURCE_FILES ./src/*.cpp sundials/src/cpodes/*.c sundials/src/cvodes/*.c sundials/src/ida/*.c sundials/src/kinsol/*.c sundials/src/nvec_ser/*.c sundials/src/sundials/*.c) FILE(GLOB SOURCE_INCLUDE_FILES ./src/*.h sundials/src/cpodes/*.h sundials/src/cvodes/*.h sundials/src/ida/*.h sundials/src/kinsol/*.h sundials/src/nvec_ser/*.h sundials/src/sundials/*.h) INCLUDE_DIRECTORIES(BEFORE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sundials/include) # # Allow automated build and dashboard. # INCLUDE (Dart) #IF (UNIX AND NOT CYGWIN AND NOT APPLE) # IF (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES Debug) # ADD_DEFINITIONS(-fprofile-arcs -ftest-coverage) # LINK_LIBRARIES(gcov) # ENDIF (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES Debug) #ENDIF (UNIX AND NOT CYGWIN AND NOT APPLE) # # Testing # ENABLE_TESTING() IF (EXECUTABLE_OUTPUT_PATH) SET (TEST_PATH ${EXECUTABLE_OUTPUT_PATH}) ELSE (EXECUTABLE_OUTPUT_PATH) SET (TEST_PATH .) ENDIF (EXECUTABLE_OUTPUT_PATH) ## These are the original C tests from Radu ADD_TEST(pend ${TEST_PATH}/pend) ADD_TEST(pendLr ${TEST_PATH}/pendLr) ADD_TEST(pendEs ${TEST_PATH}/pendEs) ADD_TEST(cpsadamsx ${TEST_PATH}/cpsadamsx) ADD_TEST(cpsbanx ${TEST_PATH}/cpsbanx) ADD_TEST(cpsbanx_lap ${TEST_PATH}/cpsbanx_lap) ADD_TEST(cpsdenx ${TEST_PATH}/cpsdenx) ADD_TEST(cpsdenx_lap ${TEST_PATH}/cpsdenx_lap) ## CVODES tests ADD_TEST(cvsadjbanx ${TEST_PATH}/cvsadjbanx) ## IDA tests ADD_TEST(idabanx1 ${TEST_PATH}/idabanx1) ## KINSOL tests ADD_TEST(kinbanx ${TEST_PATH}/kinbanx) ## These are the same tests translated to C++ by Sherm ADD_TEST(PendLrCpp ${TEST_PATH}/PendLrCpp) ADD_TEST(PendLrCppStatic ${TEST_PATH}/PendLrCppStatic) ADD_TEST(CpsAdamsXCpp ${TEST_PATH}/CpsAdamsXCpp) INCLUDE(ApiDoxygen.cmake) # # Installation # # CMake installs go into CMAKE_INSTALL_PREFIX, which is always # set to something incorrect by CMake. We'll use SimTK_INSTALL_PREFIX # instead which is passed in by the build system or set above. SET(CMAKE_INSTALL_PREFIX ${SimTK_INSTALL_PREFIX} CACHE STRING "Install path prefix." FORCE) ## Watch out -- this next line will cause CMake to find installed versions of ## SimTKcpodes libraries before the local one. Be sure to delete installed ones first. LINK_DIRECTORIES(${SimTK_SDK}/lib${LIB64}) # libraries are installed from their subdirectories; headers here # install headers FILE(GLOB SIMTK_CORE_HEADERS include/*.h) FILE(GLOB SIMTK_TOP_HEADERS include/SimTKcpodes/*.h) FILE(GLOB SIMTK_INTERNAL_HEADERS include/SimTKcpodes/internal/*.h) FILE(GLOB CPODES_HEADERS sundials/include/cpodes/*.h) FILE(GLOB CVODES_HEADERS sundials/include/cvodes/*.h) FILE(GLOB IDA_HEADERS sundials/include/ida/*.h) FILE(GLOB KINSOL_HEADERS sundials/include/kinsol/*.h) FILE(GLOB NVECTOR_HEADERS sundials/include/nvector/*.h) FILE(GLOB SUNDIALS_HEADERS sundials/include/sundials/*.h) INSTALL_FILES(/include/ FILES ${SIMTK_CORE_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/ FILES ${SIMTK_TOP_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/internal FILES ${SIMTK_INTERNAL_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/cpodes FILES ${CPODES_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/cvodes FILES ${CVODES_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/ida FILES ${IDA_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/kinsol FILES ${KINSOL_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/nvector FILES ${NVECTOR_HEADERS}) INSTALL_FILES(/include/SimTKcpodes/sundials FILES ${SUNDIALS_HEADERS})