CMAKE_MINIMUM_REQUIRED(VERSION 3.16) PROJECT(ARTIS_STAR CXX C) ENABLE_TESTING() SET(CMAKE_CXX_STANDARD 17) SET(CMAKE_CXX_STANDARD_REQUIRED ON) SET(ARTIS_MAJOR 1) SET(ARTIS_MINOR 0) SET(ARTIS_PATCH 0) SET(ARTIS_EXTRA "") SET(ARTIS_VERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}") SET(ARTIS_VERSION_SHORT "${ARTIS_MAJOR}.${ARTIS_MINOR}") SET(ARTIS_NAME "artis-star") SET(ARTIS_NAME_VERSION "${ARTIS_NAME}-${ARTIS_VERSION}") SET(ARTIS_LOCALE_NAME "${ARTIS_NAME}-${ARTIS_MAJOR}-${ARTIS_MINOR}") IF ("${ARTIS_EXTRA}" STREQUAL "") SET(ARTIS_COMPLETE "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}") ELSE ("${ARTIS_EXTRA}" STREQUAL "") SET(ARTIS_COMPLETE "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}-${ARTIS_EXTRA}") ENDIF ("${ARTIS_EXTRA}" STREQUAL "") SET(ARTIS_NAME_COMPLETE "${ARTIS_NAME}-${ARTIS_COMPLETE}") # # Installation variables # SET(ARTIS_LIBRARY_DIRS "lib/artis-star-${ARTIS_VERSION_SHORT}") SET(ARTIS_INCLUDE_DIRS "include/artis-star-${ARTIS_VERSION_SHORT}/artis-star") SET(ARTIS_INCLUDE_DIR "include/artis-star-${ARTIS_VERSION_SHORT}") SET(ARTIS_MANPAGE_PATH "share/man/man1") SET(ARTIS_SHARE_DIRS "share/artis-star-${ARTIS_VERSION_SHORT}") # # Append the library version information to the library target # properties. # SET(ARTIS_LIBRARY_PROPERTIES VERSION 0) SET(ARTIS_APP_PROPERTIES SOVERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}" VERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}") # # Debug mode # IF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++17 -pthread") IF (UNIX) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") ENDIF (UNIX) ENDIF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_BUILD_TYPE STREQUAL "") SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE) endif () # # Modules # INCLUDE(CheckIncludeFileCXX) INCLUDE(CheckIncludeFile) INCLUDE(CheckLibraryExists) INCLUDE(CMakeDetermineCCompiler) # # Boost libraries # set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.71 COMPONENTS mpi serialization unit_test_framework) # # Generate the config.h # CHECK_INCLUDE_FILE_CXX(cxxabi.h ARTIS_HAVE_GCC_ABI_DEMANGLE) CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_HAVE_EXECINFO) CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_HAVE_SIGNAL) INCLUDE_DIRECTORIES(${ARTIS_STAR_BINARY_DIR}) # # Generate the artis.pc pkg-config file. # SET(ARTIS_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}") SET(ARTIS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}") SET(ARTIS_PKGCONFIG_LIBDIR "lib") CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/artis-star.pc.in ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc @ONLY) INSTALL(FILES ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc DESTINATION lib/pkgconfig) # # Install the README # IF (UNIX) INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}") INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}") ELSE (UNIX) INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "Readme.txt") INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "CopyRight.txt") ENDIF (UNIX) # # Add sources for a target # add_sources( [ ...]) # function(ADD_SOURCES target) get_property(prop_defined GLOBAL PROPERTY ${target}_SRCS DEFINED) if(NOT prop_defined) define_property(GLOBAL PROPERTY ${target}_SRCS BRIEF_DOCS "Sources for the ${target} target" FULL_DOCS "List of source files for the ${target} target") endif() set(SRCS) foreach(src ${ARGN}) if(NOT IS_ABSOLUTE "${src}") get_filename_component(src "${src}" ABSOLUTE) endif() list(APPEND SRCS "${src}") endforeach() set_property(GLOBAL APPEND PROPERTY "${target}_SRCS" "${SRCS}") endfunction() # # Browse the src subdirectory # ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(tests) # # Status # MESSAGE(STATUS "- - - -") MESSAGE(STATUS "${ARTIS_NAME_COMPLETE} configured successfully") MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation") MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}") IF (ARTIS_HAVE_GCC_ABI_DEMANGLE) MESSAGE(STATUS "Build with GCC ABI Demangle...: yes") ENDIF (ARTIS_HAVE_GCC_ABI_DEMANGLE) IF (ARTIS_HAVE_EXECINFO) MESSAGE(STATUS "Build with execinfo.h.........: yes") ENDIF (ARTIS_HAVE_EXECINFO) IF (Boost_FOUND) MESSAGE(STATUS "Build with boost..............: yes") ENDIF (Boost_FOUND)