CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(ARTIS CXX C) ENABLE_TESTING() 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") 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-${ARTIS_VERSION_SHORT}") SET(ARTIS_INCLUDE_DIRS "include/artis-${ARTIS_VERSION_SHORT}/artis") SET(ARTIS_INCLUDE_DIR "include/artis-${ARTIS_VERSION_SHORT}") SET(ARTIS_MANPAGE_PATH "share/man/man1") SET(ARTIS_SHARE_DIRS "share/artis-${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}") # # CPack configuration # INCLUDE(CMakeCPack.cmake) # # Append debug mode when compiler is GNU. # if (CMAKE_BUILD_TYPE STREQUAL "") SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE) endif () if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++14") if ("${CMAKE_BUILD_TYPE}" EQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" EQUAL "RelWithDebInfo") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb3") endif () endif () 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) # # Check libraries with pkgconfig # FIND_PACKAGE(PkgConfig REQUIRED) # FIXME use old-style link directories for now IF (COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 OLD) ENDIF (COMMAND CMAKE_POLICY) # # Test the libboost header and libboost-text library. # SET(Boost_USE_MULTITHREADED ON) SET(Boost_USE_STATIC_LIBS OFF) SET(Boost_NO_SYSTEM_PATHS OFF) SET(Boost_USE_STATIC_RUNTIME ON) IF (WIN32) SET(Boost_THREADAPI "win32") ENDIF (WIN32) SET(Boost_DETAILED_FAILURE_MSG FALSE) SET(Boost_DEBUG FALSE) FIND_PACKAGE(Boost COMPONENTS serialization) # # 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_BINARY_DIR}) # # Generate the vle.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.pc.in ${ARTIS_BINARY_DIR}/artis-${ARTIS_VERSION_SHORT}.pc @ONLY) INSTALL(FILES ${ARTIS_BINARY_DIR}/artis-${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) # # 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) MESSAGE(STATUS "- - - -") # vim:tw=0:ts=8:tw=0:sw=2:sts=2