From 60ae840790232c52ea3f456881771edee02d35ac Mon Sep 17 00:00:00 2001 From: Maximilien Siavelis <maximilien.siavelis@simulease.com> Date: 周五, 05 1月 2018 09:10:28 +0800 Subject: [PATCH] fix some compilation issues --- /dev/null | 295 ------------------------------------------------- test/functional/date_test.cpp | 4 test/functional/generate-license.cpp | 2 test/functional/standard-license_test.cpp | 4 test/license-generator/license-generator_test.cpp | 2 CMakeLists.txt | 3 test/functional/volid_test.cpp | 12 +- 7 files changed, 13 insertions(+), 309 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e108a21..74964b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,8 +69,7 @@ SET(HAVE_64BIT_SIZE_T 0) endif(CMAKE_SIZEOF_VOID_P EQUAL 8) -include(add_boost) -add_boost(STATIC MODULES date_time test program_options system filesystem) +find_package(Boost 1.55.0 COMPONENTS date_time unit_test_framework 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 diff --git a/build/modules/add_boost.cmake b/build/modules/add_boost.cmake deleted file mode 100644 index 5498d9e..0000000 --- a/build/modules/add_boost.cmake +++ /dev/null @@ -1,295 +0,0 @@ - - -#usage add_boost( [STATIC] , -# [STATIC_RUNTIME], -# [USE_BOOST_CACHE], #If user wants to use a cache copy of Boost, get the path to this location. -# [BOOST_CACHE_DIR path], -# [TARGET_ARCHITECHTURE_32], -# [MODULES module1, module2] ) - -#This module will set the following variables -# Boost_INCLUDE_DIR - Boost include directories -# Boost_LIBRARY_DIR - Link directories for Boost libraries -# Boost_LIBRARIES - Boost component libraries to be linked -# Boost_<C>_LIBRARY - Libraries to link for component <C> (c is lower-case,may include -# target_link_libraries debug/optimized keywords) - -include (CMakeParseArguments) - -function(add_boost) - set(BoostVersion 1.55.0) - set(BoostSHA1 cef9a0cc7084b1d639e06cd3bc34e4251524c840) - - set(options STATIC STATIC_RUNTIME USE_BOOST_CACHE TARGET_ARCHITECHTURE_32) - set(oneValueArgs BOOST_CACHE_DIR) - set(multiValueArgs MODULES) - cmake_parse_arguments(ADD_BOOST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - - # Create build folder name derived from version - string(REGEX REPLACE "beta\\.([0-9])$" "beta\\1" BoostFolderName ${BoostVersion}) - string(REPLACE "." "_" BoostFolderName ${BoostFolderName}) - set(BoostFolderName boost_${BoostFolderName}) - - # If user wants to use a cache copy of Boost, get the path to this location. - #ADD_BOOST_USE_BOOST_CACHE is a parsed command line parameter - if(ADD_BOOST_USE_BOOST_CACHE) - if(ADD_BOOST_BOOST_CACHE_DIR) - file(TO_CMAKE_PATH "${BOOST_CACHE_DIR}" BoostCacheDir) - elseif(WIN32) - ms_get_temp_dir() - set(BoostCacheDir "${TempDir}") - elseif(APPLE) - set(BoostCacheDir "$ENV{HOME}/Library/Caches") - else() - set(BoostCacheDir "$ENV{HOME}/.cache") - endif() - endif() - - # If the cache directory doesn't exist, fall back to use the build root. - if(NOT IS_DIRECTORY "${BoostCacheDir}") - if(ADD_BOOST_BOOST_CACHE_DIR) - set(Message "\nThe directory \"${ADD_BOOST_BOOST_CACHE_DIR}\" provided in BOOST_CACHE_DIR doesn't exist.") - set(Message "${Message} Falling back to default path at \"${CMAKE_BINARY_DIR}/license++\"\n") - message(WARNING "${Message}") - endif() - set(BoostCacheDir ${CMAKE_BINARY_DIR}) - else() - if(NOT ADD_BOOST_USE_BOOST_CACHE AND NOT ADD_BOOST_BOOST_CACHE_DIR) - set(BoostCacheDir "${BoostCacheDir}/license++") - endif() - file(MAKE_DIRECTORY "${BoostCacheDir}") - endif() - - # Set up the full path to the source directory - set(BoostSourceDir "${BoostFolderName}_${CMAKE_CXX_COMPILER_ID}_${CMAKE_CXX_COMPILER_VERSION}") - if(HAVE_LIBC++) - set(BoostSourceDir "${BoostSourceDir}_LibCXX") - endif() - if(HAVE_LIBC++ABI) - set(BoostSourceDir "${BoostSourceDir}_LibCXXABI") - endif() - if(CMAKE_CL_64) - set(BoostSourceDir "${BoostSourceDir}_Win64") - endif() - string(REPLACE "." "_" BoostSourceDir ${BoostSourceDir}) - set(BOOST_ROOT "${BoostCacheDir}/${BoostSourceDir}" CACHE PATH "BOOST base dir") - - # Check the full path to the source directory is not too long for Windows. File paths must be less - # than MAX_PATH which is 260. The current longest relative path Boost tries to create is: - # Build\boost\bin.v2\libs\program_options\build\fd41f4c7d882e24faa6837508d6e5384\libboost_program_options-vc120-mt-gd-1_55.lib.rsp - # which along with a leading separator is 129 chars in length. This gives a maximum path available - # for 'BOOST_ROOT' as 130 chars. - if(WIN32) - get_filename_component(BoostSourceDirName "${BOOST_ROOT}" NAME) - string(LENGTH "/${BoostSourceDirName}" BoostSourceDirNameLengthWithSeparator) - math(EXPR AvailableLength 130-${BoostSourceDirNameLengthWithSeparator}) - string(LENGTH "${BOOST_ROOT}" BoostSourceDirLength) - if(${BoostSourceDirLength} GREATER 130) - set(Msg "\n\nThe path to boost's source is too long to handle all the files which will ") - set(Msg "${Msg}be created when boost is built. To avoid this, set the CMake variable ") - set(Msg "${Msg}USE_BOOST_CACHE to ON and set the variable BOOST_CACHE_DIR to a path ") - set(Msg "${Msg}which is at most ${AvailableLength} characters long. For example:\n") - set(Msg "${Msg} mkdir C:\\license_boost\n") - set(Msg "${Msg} cmake . -DUSE_BOOST_CACHE=ON -DBOOST_CACHE_DIR=C:\\license_boost\n\n") - message(FATAL_ERROR "${Msg}") - endif() - endif() - - # Download boost if required - set(ZipFilePath "${BoostCacheDir}/${BoostFolderName}.tar.bz2") - if(NOT EXISTS ${ZipFilePath}) - message(STATUS "Downloading boost ${BoostVersion} to ${BoostCacheDir}") - endif() - #SHOW_PROGRESS - file(DOWNLOAD http://sourceforge.net/projects/boost/files/boost/${BoostVersion}/${BoostFolderName}.tar.bz2/download - ${ZipFilePath} - STATUS Status - EXPECTED_HASH SHA1=${BoostSHA1} - ) - - # Extract boost if required - string(FIND "${Status}" "returning early" Found) - if(Found LESS 0 OR NOT IS_DIRECTORY "${BOOST_ROOT}") - set(BoostExtractFolder "${BoostCacheDir}/boost_unzip") - file(REMOVE_RECURSE ${BoostExtractFolder}) - file(MAKE_DIRECTORY ${BoostExtractFolder}) - file(COPY ${ZipFilePath} DESTINATION ${BoostExtractFolder}) - message(STATUS "Extracting boost ${BoostVersion} to ${BoostExtractFolder}") - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${BoostFolderName}.tar.bz2 - WORKING_DIRECTORY ${BoostExtractFolder} - RESULT_VARIABLE Result - ) - if(NOT Result EQUAL 0) - message(FATAL_ERROR "Failed extracting boost ${BoostVersion} to ${BoostExtractFolder}") - endif() - file(REMOVE ${BoostExtractFolder}/${BoostFolderName}.tar.bz2) - - # Get the path to the extracted folder - file(GLOB ExtractedDir "${BoostExtractFolder}/*") - list(LENGTH ExtractedDir n) - if(NOT n EQUAL 1 OR NOT IS_DIRECTORY ${ExtractedDir}) - message(FATAL_ERROR "Failed extracting boost ${BoostVersion} to ${BoostExtractFolder}") - endif() - file(RENAME ${ExtractedDir} ${BOOST_ROOT}) - file(REMOVE_RECURSE ${BoostExtractFolder}) - endif() - - - # Build b2 (bjam) if required - find_program(b2Path NAMES b2 PATHS ${BOOST_ROOT} NO_DEFAULT_PATH) - if(NOT b2Path) - message(STATUS "Building b2 (bjam)") - if(MSVC) - set(b2Bootstrap "bootstrap.bat") - else() - set(b2Bootstrap "./bootstrap.sh") - if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") - list(APPEND b2Bootstrap --with-toolset=clang) - elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - list(APPEND b2Bootstrap --with-toolset=gcc) - endif() - endif() - execute_process(COMMAND ${b2Bootstrap} WORKING_DIRECTORY ${BOOST_ROOT} - RESULT_VARIABLE Result OUTPUT_VARIABLE Output ERROR_VARIABLE Error) - find_program(b2Path NAMES b2 PATHS ${BOOST_ROOT} NO_DEFAULT_PATH) - if(NOT Result EQUAL 0 OR NOT b2Path) - message(FATAL_ERROR "Failed running ${b2Bootstrap}:\n${Output}\n${Error}\n") - endif() - endif() - execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BOOST_ROOT}/Build) - - #ADD_BOOST_STATIC_RUNTIME is a parsed function parameter - if(ADD_BOOST_STATIC_RUNTIME) - set(RUNTIME_LINK "static") - set(BOOST_LIB_SUFFIX "-s") - set(Boost_USE_STATIC_RUNTIME ON) - else() - set(RUNTIME_LINK "shared") - set(BOOST_LIB_SUFFIX "") - set(Boost_USE_STATIC_RUNTIME OFF) - endif() - #ADD_BOOST_STATIC is a parsed function parameter - if(ADD_BOOST_STATIC) - set(BOOST_LINK "static") - set(LINUX_LIB_EXTENSION "a") - set(WINDOWS_LIB_PREFIX "lib") - set(Boost_USE_STATIC_LIBS ON) - else(ADD_BOOST_STATIC) - set(BOOST_LINK "shared") - set(LINUX_LIB_EXTENSION "so") - set(WINDOWS_LIB_PREFIX "") - set(Boost_USE_STATIC_LIBS OFF) - endif(ADD_BOOST_STATIC) - message(STATUS "Boost linking: libs ${BOOST_LINK} , C++ runtime ${RUNTIME_LINK}") - # Set up general b2 (bjam) command line arguments - set(b2Args ./b2 - link=${BOOST_LINK} - threading=multi - runtime-link=${RUNTIME_LINK} - --build-dir=Build - stage - -d+2 - --hash - ) - if("${CMAKE_BUILD_TYPE}" STREQUAL "ReleaseNoInline") - list(APPEND b2Args cxxflags="${RELEASENOINLINE_FLAGS}") - endif() - if("${CMAKE_BUILD_TYPE}" STREQUAL "DebugLibStdcxx") - list(APPEND b2Args define=_GLIBCXX_DEBUG) - endif() - - # Set up platform-specific b2 (bjam) command line arguments - if(MSVC) - if(MSVC11) - list(APPEND b2Args toolset=msvc-11.0) - elseif(MSVC12) - list(APPEND b2Args toolset=msvc-12.0) - endif() - list(APPEND b2Args - define=_BIND_TO_CURRENT_MFC_VERSION=1 - define=_BIND_TO_CURRENT_CRT_VERSION=1 - --layout=versioned - ) - #command line parameter - if(NOT ADD_BOOST_TARGET_ARCHITECHTURE_32) - list(APPEND b2Args address-model=64) - endif() - elseif(APPLE) - list(APPEND b2Args variant=release toolset=clang cxxflags=-fPIC cxxflags=-std=c++11 cxxflags=-stdlib=libc++ - linkflags=-stdlib=libc++ architecture=combined address-model=32_64 --layout=tagged) - elseif(UNIX) - list(APPEND b2Args variant=release cxxflags=-fPIC cxxflags=-std=c++11 -sNO_BZIP2=1 --layout=tagged) - # Need to configure the toolset based on whatever version CMAKE_CXX_COMPILER is - string(REGEX MATCH "[0-9]+\\.[0-9]+" ToolsetVer "${CMAKE_CXX_COMPILER_VERSION}") - if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") - list(APPEND b2Args toolset=clang-${ToolsetVer}) - if(HAVE_LIBC++) - list(APPEND b2Args cxxflags=-stdlib=libc++ linkflags=-stdlib=libc++) - endif() - elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - list(APPEND b2Args toolset=gcc-${ToolsetVer}) - endif() - endif() - - if(NOT ADD_BOOST_MODULES) - set (ADD_BOOST_MODULES atomic chrono context coroutine date_time exception filesystem - graph iostreams log math program_options python random regex signals system - test thread timer wave) - endif() - - foreach(Component ${ADD_BOOST_MODULES}) - if(${Component} STREQUAL "test") - set(libName "unit_test_framework") - elseif(${Component} STREQUAL "math") - set(libName "math_c99l") - else() - set(libName ${Component}) - endif() - if(MSVC) - if(MSVC11) - set(CompilerName vc110) - elseif(MSVC12) - set(CompilerName vc120) - endif() - string(REGEX MATCH "[0-9]_[0-9][0-9]" Version "${BoostFolderName}") - #http://www.boost.org/doc/libs/1_42_0/more/getting_started/windows.html#library-naming - set(OUTPUT_FILE ${BOOST_ROOT}/stage/lib/${WINDOWS_LIB_PREFIX}boost_${libName}-${CompilerName}-mt-${Version}.lib) - set(OUTPUT_FILE_DEBUG ${BOOST_ROOT}/stage/lib/${WINDOWS_LIB_PREFIX}boost_${libName}-${CompilerName}-mt-gd-${Version}.lib) - else(MSVC) - set(OUTPUT_FILE ${BOOST_ROOT}/stage/lib/libboost_${libName}-mt${BOOST_LIB_SUFFIX}.${LINUX_LIB_EXTENSION}) - endif(MSVC) - #if(NOT EXISTS "${OUTPUT_FILE}") - message(STATUS "Building ${Component}: ${b2Args}") - execute_process(COMMAND ${b2Args} --with-${Component} WORKING_DIRECTORY ${BOOST_ROOT} RESULT_VARIABLE Result OUTPUT_VARIABLE Output ERROR_VARIABLE Error) - if(NOT Result EQUAL 0) - message(ERROR "Failed running ${b2Args} --with-${Component}:\n${Output}\n${Error}\n") - endif() - #endif() - endforeach() - - - LIST_REPLACE(ADD_BOOST_MODULES "test" "unit_test_framework") - # BOOST_ROOT - Preferred installation prefix - # (or BOOSTROOT) - # BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include - # BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib - # Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not - # specified by these hint variables. Default is OFF. - set (BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib CACHE PATH "BOOST library dir") - #set (Boost_NO_SYSTEM_PATHS ON) - find_package(Boost 1.55 REQUIRED COMPONENTS ${ADD_BOOST_MODULES}) - #clean up variables - mark_as_advanced (BOOST_ROOT BOOST_LIBRARYDIR) - unset(b2Path CACHE) - - set(Boost_LIBRARIES ${Boost_LIBRARIES} PARENT_SCOPE) -endfunction() - -macro(LIST_REPLACE LIST OLDVALUE NEWVALUE) - list(FIND ADD_BOOST_MODULES ${OLDVALUE} find_idx) - if(find_idx GREATER -1) - list(INSERT ${LIST} ${find_idx} ${NEWVALUE}) - MATH(EXPR __INDEX "${find_idx} + 1") - list (REMOVE_AT ${LIST} ${__INDEX}) - endif() -endmacro(LIST_REPLACE) diff --git a/test/functional/date_test.cpp b/test/functional/date_test.cpp index c15ab4e..e45f2d8 100644 --- a/test/functional/date_test.cpp +++ b/test/functional/date_test.cpp @@ -2,8 +2,8 @@ //#define BOOST_TEST_MAIN //#define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> -#include "../../../src/tools/license-generator/license-generator.h" -#include "../../../src/library/api/license++.h" +#include "../../src/tools/license-generator/license-generator.h" +#include "../../src/library/api/license++.h" #include <build_properties.h> #include <boost/filesystem.hpp> #include "../../src/library/ini/SimpleIni.h" diff --git a/test/functional/generate-license.cpp b/test/functional/generate-license.cpp index c5c9059..00fcd6a 100644 --- a/test/functional/generate-license.cpp +++ b/test/functional/generate-license.cpp @@ -6,7 +6,7 @@ */ #include <boost/test/unit_test.hpp> -#include "../../../src/tools/license-generator/license-generator.h" +#include "../../src/tools/license-generator/license-generator.h" #include <build_properties.h> #include <boost/filesystem.hpp> #include "../../src/library/ini/SimpleIni.h" diff --git a/test/functional/standard-license_test.cpp b/test/functional/standard-license_test.cpp index ec6ae45..8b49c50 100644 --- a/test/functional/standard-license_test.cpp +++ b/test/functional/standard-license_test.cpp @@ -2,8 +2,8 @@ //#define BOOST_TEST_MAIN //#define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> -#include "../../../src/tools/license-generator/license-generator.h" -#include "../../../src/library/api/license++.h" +#include "../../src/tools/license-generator/license-generator.h" +#include "../../src/library/api/license++.h" #include <build_properties.h> #include <boost/filesystem.hpp> #include "../../src/library/ini/SimpleIni.h" diff --git a/test/functional/volid_test.cpp b/test/functional/volid_test.cpp index 642f361..e9bf9ae 100644 --- a/test/functional/volid_test.cpp +++ b/test/functional/volid_test.cpp @@ -5,8 +5,8 @@ #include <fstream> #include <stdio.h> #include <cstring> -#include "../../../src/tools/license-generator/license-generator.h" -#include "../../../src/library/api/license++.h" +#include "../../src/tools/license-generator/license-generator.h" +#include "../../src/library/api/license++.h" #include <build_properties.h> #include <boost/filesystem.hpp> #include "../../src/library/ini/SimpleIni.h" @@ -22,7 +22,7 @@ PcSignature identifier_out; IDENTIFICATION_STRATEGY strategy = IDENTIFICATION_STRATEGY::ETHERNET; - BOOST_CHECKPOINT("Before generate"); + BOOST_TEST_CHECKPOINT("Before generate"); FUNCTION_RETURN generate_ok = generate_user_pc_signature(identifier_out, strategy); BOOST_ASSERT(generate_ok == FUNCTION_RETURN::FUNC_RET_OK); @@ -87,7 +87,7 @@ BOOST_ASSERT(tries > 0); PcSignature generated_identifier; - BOOST_CHECKPOINT("Generating current signatures and comparing with past"); + BOOST_TEST_CHECKPOINT("Generating current signatures and comparing with past"); for (int i = 0; i < num_strategies; i++) { FUNCTION_RETURN generate_ok = generate_user_pc_signature( generated_identifier, strategies[i]); @@ -101,7 +101,7 @@ } } - BOOST_CHECKPOINT("Verifying signatures"); + BOOST_TEST_CHECKPOINT("Verifying signatures"); for (int j = 0; j < 100; j++) { for (unsigned int i = 0; i < reference_signatures.size(); i++) { PcSignature pcsig; @@ -111,7 +111,7 @@ string message = string("pc signature verification strategy:") + to_string(i) + " generated: [" + generated_identifier + "] reference: [" + reference_signatures[i] + "]"; - BOOST_CHECKPOINT("Verifying signature: "); + BOOST_TEST_CHECKPOINT("Verifying signature: "); BOOST_CHECK_EQUAL(val_result, LICENSE_OK); } } diff --git a/test/license-generator/license-generator_test.cpp b/test/license-generator/license-generator_test.cpp index d3b396f..3cf21b3 100644 --- a/test/license-generator/license-generator_test.cpp +++ b/test/license-generator/license-generator_test.cpp @@ -2,7 +2,7 @@ //#define BOOST_TEST_MAIN //#define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> -#include "../../../src/tools/license-generator/license-generator.h" +#include "../../src/tools/license-generator/license-generator.h" #include <build_properties.h> #include <boost/filesystem.hpp> #include "../../src/library/ini/SimpleIni.h" -- Gitblit v1.9.1