X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=CMakeLists.txt;h=6aaa300db8f92c8a8fe5bb476773ffdf6b0f446b;hb=c3f6356cdc15470aa8a3603afd22cc3e213aada9;hp=a49c64357a8726f55204170e843fc6d02a372866;hpb=54032f63f2f2085b42ca173026ead62887ce6521;p=libcds.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a49c6435..6aaa300d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,26 @@ cmake_minimum_required(VERSION 2.8.12) cmake_policy(SET CMP0016 NEW) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/cmake ${CMAKE_MODULE_PATH}) +include(TargetArch) project(cds) -set(PROJECT_VERSION 2.1.0) +set(PROJECT_VERSION 2.2.0) # Options option(WITH_TESTS "Build unit tests" OFF) option(WITH_TESTS_COVERAGE "Analyze test coverage using gcov (only for gcc)" OFF) option(WITH_BOOST_ATOMIC "Use boost atomics (only for boost >= 1.54)" OFF) +option(WITH_ASAN "Build AddressSantinizer instrumented code" OFF) +option(WITH_TSAN "Build ThreadSantinizer instrumented code" OFF) find_package(Threads REQUIRED) find_package(Boost 1.50 COMPONENTS system thread REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) +target_architecture(CMAKE_TARGET_ARCHITECTURE) + if(WITH_BOOST_ATOMIC) if(${Boost_MINOR_VERSION} GREATER 53) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCDS_USE_BOOST_ATOMIC") @@ -22,6 +28,26 @@ if(WITH_BOOST_ATOMIC) endif() endif(WITH_BOOST_ATOMIC) +if(WITH_ASAN) + if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fPIC -fsanitize=address -g -fno-omit-frame-pointer -fno-optimize-sibling-calls") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fsanitize=address -g -fno-omit-frame-pointer -fno-optimize-sibling-calls") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -pie") + else() + message(WARNING "Compiler does not support AddressSanitizer") + endif() +endif(WITH_ASAN) + +if(WITH_TSAN) + if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fPIC -fsanitize=thread -g -DCDS_THREAD_SANITIZER_ENABLED -fno-omit-frame-pointer") + set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fPIC -fsanitize=thread -g -DCDS_THREAD_SANITIZER_ENABLED -fno-omit-frame-pointer") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -pie") + else() + message(WARNING "Compiler does not support ThreadSanitizer") + endif() +endif(WITH_TSAN) + if(WITH_TESTS_COVERAGE) if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") @@ -39,24 +65,43 @@ set(CDS_STATIC_LIBRARY ${PROJECT_NAME}-s) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +if(CDS_BIN_DIR) + set(EXECUTABLE_OUTPUT_PATH ${CDS_BIN_DIR}) + set(LIBRARY_OUTPUT_PATH ${CDS_BIN_DIR}) +else() + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +endif() +message(STATUS "Binary output path: ${EXECUTABLE_OUTPUT_PATH}") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "Default build type to Debug" FORCE) endif() -message("Build type -- ${CMAKE_BUILD_TYPE}") - -if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -fno-strict-aliasing") -# gcc 4.8: disable noise -Wunused-local-typedefs - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs -Wno-unused-parameter") +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic -fno-strict-aliasing") + if(CMAKE_TARGET_ARCHITECTURE STREQUAL "x86_64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcx16") + endif() + if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0.0") +# gcc 4.8 - 6: disable noise -Wunused-local-typedefs + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs") + endif() endif() set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") +message("Build type -- ${CMAKE_BUILD_TYPE}") +message("Compiler version: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") +MESSAGE("Target architecture: ${CMAKE_TARGET_ARCHITECTURE}") +if (CMAKE_BUILD_TYPE STREQUAL "DEBUG") + message("Compiler flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") +else() + message("Compiler flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") +endif() +message("Boost: ${Boost_LIB_VERSION} in ${Boost_INCLUDE_DIRS}, lib ${Boost_LIBRARY_DIRS}") + + include_directories(${PROJECT_SOURCE_DIR}) # Component names for separate distribution in rpms, debs etc. @@ -75,9 +120,12 @@ set(SOURCES src/hp_gc.cpp src/dllmain.cpp) add_library(${CDS_SHARED_LIBRARY} SHARED ${SOURCES}) +set_target_properties( ${CDS_SHARED_LIBRARY} PROPERTIES VERSION ${PROJECT_VERSION} + DEBUG_POSTFIX "_d") add_library(${CDS_STATIC_LIBRARY} STATIC ${SOURCES}) -target_link_libraries(${CDS_SHARED_LIBRARY} PRIVATE ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -target_link_libraries(${CDS_STATIC_LIBRARY} PRIVATE ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +set_target_properties(${CDS_STATIC_LIBRARY} PROPERTIES DEBUG_POSTFIX "_d") +target_link_libraries(${CDS_SHARED_LIBRARY} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(${CDS_STATIC_LIBRARY} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS ${CDS_SHARED_LIBRARY} DESTINATION lib COMPONENT ${LIBRARIES_COMPONENT}) install(TARGETS ${CDS_STATIC_LIBRARY} DESTINATION lib COMPONENT ${LIBRARIES_COMPONENT}) @@ -85,7 +133,7 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/cds DESTINATION include COMPONENT ${HEAD if(WITH_TESTS) enable_testing() - add_subdirectory(${PROJECT_SOURCE_DIR}/tests) + add_subdirectory(${PROJECT_SOURCE_DIR}/test) message(STATUS "Build tests: activated") endif(WITH_TESTS)