From 897303206e87db7616b8c5f11b894c94b1047e7c Mon Sep 17 00:00:00 2001 From: open-license-manager <rillf@maildrop.cc> Date: 周一, 08 9月 2014 05:59:02 +0800 Subject: [PATCH] Merge branch 'master' of https://github.com/open-license-manager/open-license-manager.git --- CMakeLists.txt | 75 +++++++++++++++++++------------------ 1 files changed, 38 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4a22b1..fe14f24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,8 @@ -cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) +#TODO guess address_model 64 in boost +#make it compatible with find_boost (exchange lowercase to camelcase) +#fix shared libraries activation + +cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) #version variables, major and minor must be 1 character only SET(LICENSECC_MAJOR_VERSION 1) @@ -11,12 +15,19 @@ # add this options before PROJECT keyword SET(CMAKE_DISABLE_SOURCE_CHANGES OFF) SET(CMAKE_DISABLE_IN_SOURCE_BUILD ON) - SET(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "CMake verbose" FORCE) project (license++ C CXX) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/modules/") + +include(utilities) +if(CMAKE_BUILD_TYPE) + string(TOLOWER ${CMAKE_BUILD_TYPE} _CMAKE_BUILD_TYPE) + EVAL_CONDITION(RELEASE_BUILD ${_CMAKE_BUILD_TYPE} STREQUAL "release") +else(CMAKE_BUILD_TYPE) + set(RELEASE_BUILD 0) +endif(CMAKE_BUILD_TYPE) if(WIN32) SET(PLATFORM_LIBS "") @@ -26,18 +37,23 @@ SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES} add_definitions("/D_CRT_SECURE_NO_WARNINGS") else(WIN32) - SET(PLATFORM_LIBS "m") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -fmessage-length=0 -std=c++11 -Wall -Wuninitialized -fPIC") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -fmessage-length=0 -std=c++11 -Wuninitialized -fPIC") #-Wall SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -fmessage-length=0 -Wall -Wuninitialized -fPIC") - SET(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -pipe" CACHE INTERNAL "Linker flags") - SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} -Wl,--strip-all") - SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) #.so for dynamic libraries + #use static libraries in release to make it easier to distribute it + #SET(Boost_USE_STATIC_RUNTIME ${RELEASE_BUILD}) + if(RELEASE_BUILD) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) #.so for dynamic libraries + else() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) + endif() + set (CMAKE_EXE_LINKER_FLAGS "-pthread") + SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,--strip-all -static-libstdc++") #-static #you need to "force" the change in cmake_install_prefix after the project keyword IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix" FORCE) ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) endif(WIN32) - +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>) if(CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -45,21 +61,13 @@ else(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(HAVE_64BIT_SIZE_T 0) endif(CMAKE_SIZEOF_VOID_P EQUAL 8) -set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) -#find_package(CryptoPP REQUIRED) -#include_directories(${CRYPTOPP_INCLUDE_DIRS}) -#link_directories ( ${Boost_LIBRARY_DIRS} ) - - -SET(Boost_USE_STATIC_LIBS ON) -# static runtime requires /MT -#SET(Boost_USE_MULTITHREADED ON) #SET(Boost_USE_STATIC_RUNTIME OFF) -#find_package(Boost COMPONENTS thread date_time program_options filesystem system regex unit_test_framework) -find_package(Boost COMPONENTS date_time program_options filesystem system unit_test_framework) -#include_directories(${Boost_INCLUDE_DIRS}) -#link_directories ( ${Boost_LIBRARY_DIRS} ) - +include(add_boost) +add_boost(STATIC MODULES date_time test program_options system filesystem) +#set below in case of dynamic linking in debug. +#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>) +add_definitions(-DBOOST_ALL_NO_LIB) #Disable Boost Microsoft magic, all dependencies are handled by cmake +add_definitions(-DBOOST_LIB_DIAGNOSTIC) #Check it is really disabled if(NOT WIN32) #find a static version of openssl crypto library @@ -70,6 +78,7 @@ include_directories(${DBUS_INCLUDE_DIR}) include_directories(${DBUS_ARCH_INCLUDE_DIR}) list(APPEND EXTERNAL_LIBS ${DBUS_LIBRARIES}) + list(APPEND EXTERNAL_LIBS dl) endif(NOT WIN32) FIND_PACKAGE(Doxygen) @@ -110,16 +119,13 @@ add_subdirectory(src) -#test are done with boost_tests:disable them if boost not found. -IF(Boost_FOUND) - ENABLE_TESTING() - INCLUDE(CTest) - IF(BUILD_TESTING) - SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard") - MARK_AS_ADVANCED(BUILDNAME) - ENDIF(BUILD_TESTING) - add_subdirectory(test) -ENDIF(Boost_FOUND) +INCLUDE(CTest) +ENABLE_TESTING() +IF(BUILD_TESTING) + SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard") + MARK_AS_ADVANCED(BUILDNAME) +ENDIF(BUILD_TESTING) +add_subdirectory(test) #include(build/modules/CmakeDebugVariables.txt) @@ -130,11 +136,6 @@ message( STATUS "Build type: " ${CMAKE_BUILD_TYPE}) endif(CMAKE_BUILD_TYPE) message( STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX}) -IF(Boost_FOUND) - message( STATUS "Boost found: running a complete build.") -ELSE(Boost_FOUND) - message( STATUS "Boost not found: tests, pc-identifier will be skipped") -ENDIF(Boost_FOUND) if(DOXYGEN_FOUND) message(STATUS "Doxygen: " ${DOXYGEN_EXECUTABLE}) else(DOXYGEN_FOUND) -- Gitblit v1.9.1