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_STAR_MAJOR 1) SET(ARTIS_STAR_MINOR 0) SET(ARTIS_STAR_PATCH 0) SET(ARTIS_STAR_EXTRA "") SET(ARTIS_STAR_VERSION "${ARTIS_STAR_MAJOR}.${ARTIS_STAR_MINOR}.${ARTIS_STAR_PATCH}") SET(ARTIS_STAR_VERSION_SHORT "${ARTIS_STAR_MAJOR}.${ARTIS_STAR_MINOR}") SET(ARTIS_STAR_NAME "artis-star") SET(ARTIS_STAR_NAME_VERSION "${ARTIS_STAR_NAME}-${ARTIS_STAR_VERSION}") SET(ARTIS_STAR_LOCALE_NAME "${ARTIS_STAR_NAME}-${ARTIS_STAR_MAJOR}-${ARTIS_STAR_MINOR}") IF ("${ARTIS_STAR_EXTRA}" STREQUAL "") SET(ARTIS_STAR_COMPLETE "${ARTIS_STAR_MAJOR}.${ARTIS_STAR_MINOR}.${ARTIS_STAR_PATCH}") ELSE ("${ARTIS_STAR_EXTRA}" STREQUAL "") SET(ARTIS_STAR_COMPLETE "${ARTIS_STAR_MAJOR}.${ARTIS_STAR_MINOR}.${ARTIS_STAR_PATCH}-${ARTIS_STAR_EXTRA}") ENDIF ("${ARTIS_STAR_EXTRA}" STREQUAL "") SET(ARTIS_STAR_NAME_COMPLETE "${ARTIS_STAR_NAME}-${ARTIS_STAR_COMPLETE}") # # Installation variables # SET(ARTIS_STAR_LIBRARY_DIRS "lib/artis-star-${ARTIS_STAR_VERSION_SHORT}") SET(ARTIS_STAR_INCLUDE_DIRS "include/artis-star-${ARTIS_STAR_VERSION_SHORT}/artis-star") SET(ARTIS_STAR_INCLUDE_DIR "include/artis-star-${ARTIS_STAR_VERSION_SHORT}") SET(ARTIS_STAR_MANPAGE_PATH "share/man/man1") SET(ARTIS_STAR_SHARE_DIRS "share/artis-star-${ARTIS_STAR_VERSION_SHORT}") # # Append the library version information to the library target # properties. # SET(ARTIS_STAR_LIBRARY_PROPERTIES VERSION 0) SET(ARTIS_STAR_APP_PROPERTIES SOVERSION "${ARTIS_STAR_MAJOR}.${ARTIS_STAR_MINOR}" VERSION "${ARTIS_STAR_MAJOR}.${ARTIS_STAR_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_STAR_HAVE_GCC_ABI_DEMANGLE) CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_STAR_HAVE_EXECINFO) CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_STAR_HAVE_SIGNAL) INCLUDE_DIRECTORIES(${ARTIS_STAR_BINARY_DIR}) # # Generate the artis.pc pkg-config file. # SET(ARTIS_STAR_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}") SET(ARTIS_STAR_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}") SET(ARTIS_STAR_PKGCONFIG_LIBDIR "lib") CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/artis-star.pc.in ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_STAR_VERSION_SHORT}.pc @ONLY) INSTALL(FILES ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_STAR_VERSION_SHORT}.pc DESTINATION lib/pkgconfig) # # Install the README # IF (UNIX) INSTALL(FILES "README" DESTINATION "${ARTIS_STAR_SHARE_DIRS}") INSTALL(FILES "COPYING" DESTINATION "${ARTIS_STAR_SHARE_DIRS}") ELSE (UNIX) INSTALL(FILES "README" DESTINATION "${ARTIS_STAR_SHARE_DIRS}" RENAME "Readme.txt") INSTALL(FILES "COPYING" DESTINATION "${ARTIS_STAR_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_STAR_NAME_COMPLETE} configured successfully") MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation") MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}") IF (ARTIS_STAR_HAVE_GCC_ABI_DEMANGLE) MESSAGE(STATUS "Build with GCC ABI Demangle...: yes") ENDIF (ARTIS_STAR_HAVE_GCC_ABI_DEMANGLE) IF (ARTIS_STAR_HAVE_EXECINFO) MESSAGE(STATUS "Build with execinfo.h.........: yes") ENDIF (ARTIS_STAR_HAVE_EXECINFO) IF (Boost_FOUND) MESSAGE(STATUS "Build with boost..............: yes") ENDIF (Boost_FOUND)