From 4803310de7537094a00cc96be3830d18f9ec91dd Mon Sep 17 00:00:00 2001 From: gcontini <1121667+gcontini@users.noreply.github.com> Date: 周六, 30 11月 2019 17:57:31 +0800 Subject: [PATCH] enable c++ 1.1 for old compilers --- test/library/CMakeLists.txt | 15 ---- /dev/null | 137 --------------------------------------------- CMakeLists.txt | 5 + 3 files changed, 5 insertions(+), 152 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd4700d..3a5ccea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,13 +23,14 @@ ENDIF(NOT LCC_PROJECTS_BASE_DIR) project (licensecc C CXX ) -SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") #find lcc executable or build it. find_package(lcc REQUIRED) -#My system doesn't support binfmt misc +#In case the build system doesn't support binfmt misc IF( ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" ) AND CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR ) SET(CMAKE_CROSSCOMPILING_EMULATOR "wine") ENDIF() diff --git a/CMakeLists.txt.bak b/CMakeLists.txt.bak deleted file mode 100644 index edd91f9..0000000 --- a/CMakeLists.txt.bak +++ /dev/null @@ -1,137 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) - -#version variables, major and minor must be 1 character only -SET(LICENSECC_MAJOR_VERSION 1) -SET(LICENSECC_MINOR_VERSION 1) -SET(LICENSECC_PATCH_VERSION 0 CACHE STRING "Licensecc patch version string") -SET(LICENSECC_INT_VERSION "${LICENSECC_MAJOR_VERSION}${LICENSECC_MINOR_VERSION}${LICENSECC_PATCH_VERSION}") -SET(LICENSECC_VERSION "${LICENSECC_MAJOR_VERSION}.${LICENSECC_MINOR_VERSION}.${LICENSECC_PATCH_VERSION}") -SET(LICENSECC_SHORT_LICENSE "BSD Software License") - -SET(CMAKE_DISABLE_SOURCE_CHANGES ON) -SET(CMAKE_DISABLE_IN_SOURCE_BUILD ON) - -project (licensecc C CXX ) -SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") - -include(utilities) #import module utilities.cmake -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(MSVC) - SET(PLATFORM_LIBS "") - include(target_arch) - target_architecture( TARGET_ARCHITECTURE ) - message(STATUS "architecture detected: ${TARGET_ARCHITECTURE}") - - #Boost > 3.15 handle the /MD flag more nicely than this - if(${STATIC_RUNTIME}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - SET(Boost_USE_STATIC_RUNTIME ON) - endif(${STATIC_RUNTIME}) - - #SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES} - add_definitions("/D _CRT_SECURE_NO_WARNINGS") -else(MSVC) - #GCC or Mingw - 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 "-pthread -static-libstdc++") - SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,--strip-all -static-libstdc++") #-static - if(MINGW) - list(APPEND EXTERNAL_LIBS "-lcrypt32 -lws2_32 -liphlpapi") - SET(CMAKE_EXE_LINKER_FLAGS "-static") - endif(MINGW) - - if(USE_DBUS_IDENTIFIER) - FIND_PACKAGE(Dbus REQUIRED) - add_definitions(-DUSE_DBUS) - include_directories(${DBUS_INCLUDE_DIR}) - include_directories(${DBUS_ARCH_INCLUDE_DIR}) - list(APPEND EXTERNAL_LIBS ${DBUS_LIBRARIES}) - endif(USE_DBUS_IDENTIFIER) -endif(MSVC) - -if(UNIX) #this is true for all the linux systems but not for cross compiling - #find a static version of openssl crypto library - SET ( OPENSSL_USE_STATIC_LIBS ON ) - find_package(OpenSSL REQUIRED COMPONENTS Crypto) - include_directories(${OPENSSL_INCLUDE_DIR}) - list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY}) - MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} ") - #Zlib required when openssl version < 1.0.1f - SET ( ZLIB_USE_STATIC_LIBS ON ) - find_package(ZLIB REQUIRED) - list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES}) - MESSAGE(STATUS "Found zlib version ${ZLIB_VERSION} ") - if(NOT MINGW) - list(APPEND EXTERNAL_LIBS "-ldl") - endif(NOT MINGW) - find_program( MEMORYCHECK_COMMAND valgrind ) - set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" ) -endif(UNIX) - -SET_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(HAVE_64BIT_SIZE_T 1) -else(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(HAVE_64BIT_SIZE_T 0) -endif(CMAKE_SIZEOF_VOID_P EQUAL 8) - -#bug in cmake win32 - can't find boost compiled with mingw -if(WIN32 AND "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x") - message(WARNING "WIN32 compiler does not specify CMAKE_CXX_COMPILER_ARCHITECTURE_ID -- filling in manually") - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x64") - else() - set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x86") - endif() - message(STATUS "Compiler architecture: ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") -endif() - -SET( Boost_USE_STATIC_LIBS ON ) -find_package(Boost REQUIRED 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 -add_definitions(-DBOOST_LIB_DIAGNOSTIC) #Check it is really disabled - -configure_file ( - "src/build_properties.h.in" - "${CMAKE_BINARY_DIR}/build_properties.h" -) - -message( STATUS "C compiler : " ${CMAKE_C_COMPILER}) -message( STATUS "C compiler flags : " ${CMAKE_C_FLAGS}) -message( STATUS "CXX compiler : " ${CMAKE_CXX_COMPILER}) -message( STATUS "CXX compiler flags: " ${CMAKE_CXX_FLAGS}) -message( STATUS "CXX compiler flags debug : " ${CMAKE_CXX_FLAGS_DEBUG}) -message( STATUS "CXX compiler flags release: " ${CMAKE_CXX_FLAGS_RELEASE}) -if(CMAKE_BUILD_TYPE) - message( STATUS "Build type : " ${CMAKE_BUILD_TYPE}) -endif(CMAKE_BUILD_TYPE) -message( STATUS "Install prefix : " ${CMAKE_INSTALL_PREFIX}) - -#include build directory to find build_properties.h -include_directories(${CMAKE_BINARY_DIR}) - -add_subdirectory(src) - -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) - - diff --git a/test/library/CMakeLists.txt b/test/library/CMakeLists.txt index 481cacd..382dcb5 100644 --- a/test/library/CMakeLists.txt +++ b/test/library/CMakeLists.txt @@ -9,12 +9,7 @@ ${Boost_LIBRARIES} ) -IF( ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") AND CMAKE_CROSSCOMPILING) -#binfmt_misc doesn't work in my system :( - ADD_TEST(NAME test_license_reader COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/test_license_reader) -ELSE() - ADD_TEST(NAME test_license_reader COMMAND test_license_reader) -ENDIF() +ADD_TEST(NAME test_license_reader COMMAND test_license_reader) IF(WIN32) #test windows @@ -33,7 +28,6 @@ ADD_TEST(NAME test_os_linux COMMAND test_os_linux) ENDIF(WIN32) - ### LicenseLocator tests add_executable( test_license_locator @@ -46,12 +40,7 @@ ${Boost_LIBRARIES} ) -IF( ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") AND CMAKE_CROSSCOMPILING) -#binfmt_misc doesn't work in my system :( - ADD_TEST(NAME test_license_locator COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/test_license_locator) -ELSE() - ADD_TEST(NAME test_license_locator COMMAND test_license_locator) -ENDIF() +ADD_TEST(NAME test_license_locator COMMAND test_license_locator) ### LicenseLocator tests add_executable( -- Gitblit v1.9.1