#################################################### # # # SpecMiCP : CMakeLists.txt # # # #################################################### project(specmicp) cmake_minimum_required(VERSION 2.8.8) # Configuration options # ====================== # For an explanation of the options see the INSTALL file option(SPECMICP_USE_OPENMP "Thread parallelisation of specmicp instances if available" ON) option(SPECMICP_NO_DEBUG "Disable SpecMiCP assert" OFF) option(SPECMICP_BUILD_STATIC "Build static libraries" OFF) option(SPECMICP_BUILD_EXAMPLE "Build the examples" ON) option(SPECMICP_DEBUG_EQUATION_FD_JACOBIAN "Use a finite difference jacobian is specmicp" OFF) # global variables # ================ set(SPECMICP_VERSION 0.0.3) # External Package # ================ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") # OpenMP #------- # not required but recommended find_package(OpenMP) # Boost # ----- find_package(Boost REQUIRED) include_directories(${Boost_INCLUDE_DIR}) # Eigen # ----- find_package(Eigen3 REQUIRED) # This module comes from the Eigen3 Package include_directories(${EIGEN3_INCLUDE_DIR}) # Eigen unsuported # GMRES.h is really the file we are using/looking for # If it doesn't exist then the solver will not be included in the list of the parse solvers if(EXISTS "${EIGEN3_INCLUDE_DIR}/unsupported/Eigen/src/IterativeSolvers/GMRES.h") add_definitions(-DEIGEN_UNSUPPORTED_FOUND) INCLUDE_DIRECTORIES("${EIGEN3_INCLUDE_DIR}/unsupported/") endif() # compilation flags # ================= # c++11 # ----- include(CheckCXXCompilerFlag) if(NOT CX11_FLAG) check_cxx_compiler_flag("-std=c++11" HAS_CXX11) if(NOT HAS_CXX11) message(FATAL_ERROR "A c++11 compatible compiler is necessary") else() set(CXX11_FLAG "-std=c++11") endif() endif() if(UNIX) # Use ld.gold if it is available and isn't disabled explicitly # Ref : https://bugs.webkit.org/show_bug.cgi?id=137953 option(USE_LD_GOLD "Use GNU gold linker" ON) if (USE_LD_GOLD) execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) if ("${LD_VERSION}" MATCHES "GNU gold") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") else () message(WARNING "GNU gold linker isn't available, using the default system linker.") endif () endif () # Generic options SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAG}") if (OPENMP_FOUND) SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") endif() SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pedantic") ##SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") message(STATUS "c++ flags ${CMAKE_CXX_FLAGS}") else() message(WARNING "not tested !") endif() # Directories ######################################################################### # 3rd party # ========= # JsonCPP # ------- set(JSONCPP_DIR ${PROJECT_SOURCE_DIR}/3rdparty/jsoncpp/) add_custom_target(3rdparty_header SOURCES ${JSONCPP_DIR}/json/json.h ${JSONCPP_DIR}/json/json-forwards.h ) include_directories(${JSONCPP_DIR}) # installation dir # ---------------- # http://www.cmake.org/pipermail/cmake/2010-February/035466.html # compute default library install dir if(UNIX) # library # ------ set (_DEFAULT_LIBRARY_INSTALL_DIR lib) if (EXISTS "${CMAKE_INSTALL_PREFIX}/lib32/" AND CMAKE_SIZEOF_VOID_P EQUAL 4) set (_DEFAULT_LIBRARY_INSTALL_DIR lib32) elif (EXISTS "${CMAKE_INSTALL_PREFIX}/lib64/" AND CMAKE_SIZEOF_VOID_P EQUAL 8) set (_DEFAULT_LIBRARY_INSTALL_DIR lib64) endif () # the library install dir set(LIBRARY_INSTALL_DIR "${_DEFAULT_LIBRARY_INSTALL_DIR}" CACHE PATH "Installation directory for libraries") set(STATIC_LIBRARY_INSTALL_DIR "${_DEFAULT_LIBRARY_INSTALL_DIR}/static" CACHE PATH "Installation directory for static libraries") # make the library install dir an absolute path (can be important e.g. when using CONFIGURE_FILE to embed # the library installation directory into a file) if(NOT IS_ABSOLUTE "${LIBRARY_INSTALL_DIR}") set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIR}") endif() if(NOT IS_ABSOLUTE "${STATIC_LIBRARY_INSTALL_DIR}") set(STATIC_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${STATIC_LIBRARY_INSTALL_DIR}") endif() # include #-------- set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/specmicp") # share #------ set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/specmicp") else() message(WARNING "not tested !") endif() # CPP API : SpecMiCP / ReactMiCP ######################################################################### # the main source directory - the c++ api set(SPECMICP_CPP_API ${CMAKE_CURRENT_SOURCE_DIR}/src) include_directories(${SPECMICP_CPP_API}) add_subdirectory( ${SPECMICP_CPP_API} ) # Database ######################################################################### add_subdirectory( data ) # Documentation ######################################################################### # "common" documentation # ----------------------- set( DOCS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/COPYING ) add_custom_target(docs SOURCES ${DOCS_LIST}) install(FILES ${DOCS_LIST} DESTINATION ${SHARE_INSTALL_DIR} ) # Doxygen documentation # --------------------- add_subdirectory( doc ) # the cmake find module # --------------------- install(FILES cmake/FindSpecMiCP.cmake DESTINATION ${SHARE_INSTALL_DIR}/cmake ) # The following modules have their own CMakeLists.txt # Python interface ######################################################################### add_subdirectory( cython ) # Tests ######################################################################### add_subdirectory( tests ) # Examples ######################################################################### add_subdirectory( examples )