diff --git a/CMakeLists.txt b/CMakeLists.txt index 86cd903..38590f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,64 +167,65 @@ else() target_link_libraries(inmemorybenchmarksnappy FastPFOR ${snappy_LIBRARIES}) endif() -# Download and unpack googletest at configure time -configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) -if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") -endif() -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) -if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") -endif() - -# Prevent GoogleTest from overriding our compiler/linker options -# when building with Visual Studio -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - -# Add googletest directly to our build. This adds -# the following targets: gtest, gtest_main, gmock -# and gmock_main -add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src - ${CMAKE_CURRENT_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL) - -# The gtest/gmock targets carry header search path -# dependencies automatically when using CMake 2.8.11 or -# later. Otherwise we have to add them here ourselves. -if(CMAKE_VERSION VERSION_LESS 2.8.11) - include_directories("${gtest_SOURCE_DIR}/include" - "${gmock_SOURCE_DIR}/include") -endif() - -add_executable(codecs src/codecs.cpp) -target_link_libraries(codecs FastPFOR) - -add_executable(example example.cpp) -target_link_libraries(example FastPFOR) - -add_executable(inmemorybenchmark src/inmemorybenchmark.cpp) -target_link_libraries(inmemorybenchmark FastPFOR) - -add_executable(unit src/unit.cpp) -target_link_libraries(unit FastPFOR) -add_custom_target(check unit DEPENDS unit) - - -add_executable(FastPFOR_unittest +option(WITH_TEST "Build with Google Test" ON) + +if(WITH_TEST) + # Download and unpack googletest at configure time + configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) + if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) + if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") + endif() + + # Prevent GoogleTest from overriding our compiler/linker options + # when building with Visual Studio + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + + # Add googletest directly to our build. This adds + # the following targets: gtest, gtest_main, gmock + # and gmock_main + add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL) + + # The gtest/gmock targets carry header search path + # dependencies automatically when using CMake 2.8.11 or + # later. Otherwise we have to add them here ourselves. + if(CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include" + "${gmock_SOURCE_DIR}/include") + endif() + + add_executable(codecs src/codecs.cpp) + target_link_libraries(codecs FastPFOR) + + add_executable(example example.cpp) + target_link_libraries(example FastPFOR) + + add_executable(inmemorybenchmark src/inmemorybenchmark.cpp) + target_link_libraries(inmemorybenchmark FastPFOR) + + add_executable(unit src/unit.cpp) + target_link_libraries(unit FastPFOR) + add_custom_target(check unit DEPENDS unit) + + add_executable(FastPFOR_unittest unittest/test_composite.cpp unittest/test_driver.cpp unittest/test_fastpfor.cpp unittest/test_variablebyte.cpp) -target_link_libraries(FastPFOR_unittest gtest FastPFOR) -enable_testing() -add_test("unit" unit) -add_test("FastPFOR_unittest" FastPFOR_unittest) - + target_link_libraries(FastPFOR_unittest gtest FastPFOR) + enable_testing() + add_test("FastPFOR_unittest" FastPFOR_unittest) +endif() include(GNUInstallDirs) install(TARGETS FastPFOR @@ -255,4 +256,4 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.0.0) endif() configure_file("fastpfor.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/fastpfor.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/fastpfor.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") \ No newline at end of file