From 88ababd125220ae4c98272f205122c48c42226a2 Mon Sep 17 00:00:00 2001 From: theNerd247 Date: Sun, 12 Jun 2016 18:28:07 -0400 Subject: [PATCH 1/3] added system installation configuration * added rapidcheck-config.cmake generation/installation * added include/ paths to installation (for extras/ and main project). --- CMakeLists.txt | 35 ++++++++++++++++++++++++++++++++ extras/boost/CMakeLists.txt | 6 +++++- extras/boost_test/CMakeLists.txt | 4 ++++ extras/catch/CMakeLists.txt | 6 +++++- extras/gmock/CMakeLists.txt | 6 +++++- extras/gtest/CMakeLists.txt | 4 ++++ rapidcheck-config.cmake.in | 7 +++++++ 7 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 rapidcheck-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ef8e3182..5b2fe17d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,10 @@ enable_testing() option(RC_ENABLE_TESTS "Build RapidCheck tests" OFF) option(RC_ENABLE_EXAMPLES "Build RapidCheck examples" OFF) +set(cmake_config_files + "rapidcheck-config.cmake" + ) + if(MSVC) # /bigobj - some object files become very large so we need this # /wd4503 - truncation of decorated name, not much we can do about it so @@ -76,3 +80,34 @@ if (RC_ENABLE_EXAMPLES) endif() add_subdirectory(extras) + +# install the targets and include directories +install(TARGETS rapidcheck + ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" + ) + +install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) + +# setup the cmake config files +# the include directories to export in our cmake config file +set(CONFIG_INCLUDE_DIRS + "${CMAKE_INSTALL_PREFIX}/include" + ) + +# The libraries to export in our cmake config file +set(CONFIG_LIBRARIES "rapidcheck") + +# generate the cmake config files +foreach(f ${cmake_config_files}) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${f}.in" + "${PROJECT_BINARY_DIR}/${f}" + @ONLY + ) + + install( + FILES "${PROJECT_BINARY_DIR}/${f}" + DESTINATION "lib/cmake/rapidcheck" + ) +endforeach() diff --git a/extras/boost/CMakeLists.txt b/extras/boost/CMakeLists.txt index b5fd8eec..d8ab1816 100644 --- a/extras/boost/CMakeLists.txt +++ b/extras/boost/CMakeLists.txt @@ -4,4 +4,8 @@ target_include_directories(rapidcheck_boost INTERFACE include) if (RC_ENABLE_TESTS) add_subdirectory(test) -endif() \ No newline at end of file +endif() + +install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) diff --git a/extras/boost_test/CMakeLists.txt b/extras/boost_test/CMakeLists.txt index 1d95a3c6..bfafd168 100644 --- a/extras/boost_test/CMakeLists.txt +++ b/extras/boost_test/CMakeLists.txt @@ -1,3 +1,7 @@ add_library(rapidcheck_boost_test INTERFACE) target_link_libraries(rapidcheck_boost_test INTERFACE rapidcheck) target_include_directories(rapidcheck_boost_test INTERFACE include) + +install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) diff --git a/extras/catch/CMakeLists.txt b/extras/catch/CMakeLists.txt index 425b3b32..ecb28a16 100644 --- a/extras/catch/CMakeLists.txt +++ b/extras/catch/CMakeLists.txt @@ -1,3 +1,7 @@ add_library(rapidcheck_catch INTERFACE) target_link_libraries(rapidcheck_catch INTERFACE rapidcheck) -target_include_directories(rapidcheck_catch INTERFACE include) \ No newline at end of file +target_include_directories(rapidcheck_catch INTERFACE include) + +install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) diff --git a/extras/gmock/CMakeLists.txt b/extras/gmock/CMakeLists.txt index 9e620010..9876c76f 100644 --- a/extras/gmock/CMakeLists.txt +++ b/extras/gmock/CMakeLists.txt @@ -4,4 +4,8 @@ target_include_directories(rapidcheck_gmock INTERFACE include) if (RC_ENABLE_TESTS) add_subdirectory(test) -endif() \ No newline at end of file +endif() + +install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) diff --git a/extras/gtest/CMakeLists.txt b/extras/gtest/CMakeLists.txt index ee7b3a3b..c66d6d1a 100644 --- a/extras/gtest/CMakeLists.txt +++ b/extras/gtest/CMakeLists.txt @@ -1,3 +1,7 @@ add_library(rapidcheck_gtest INTERFACE) target_link_libraries(rapidcheck_gtest INTERFACE rapidcheck) target_include_directories(rapidcheck_gtest INTERFACE include) + +install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) diff --git a/rapidcheck-config.cmake.in b/rapidcheck-config.cmake.in new file mode 100644 index 00000000..0901d872 --- /dev/null +++ b/rapidcheck-config.cmake.in @@ -0,0 +1,7 @@ +#When run this file will define the following CMake cached variables: +# +# rapidcheck_INCLUDE_DIRS +# rapidcheck_LIBRARIES +# +set(rapidcheck_INCLUDE_DIRS "@CONFIG_INCLUDE_DIRS@") +set(rapidcheck_LIBRARIES "@CONFIG_LIBRARIES@") From 4ef3aa52bc5e5321a4a1654c66b6cfbd35e10778 Mon Sep 17 00:00:00 2001 From: theNerd247 Date: Sun, 12 Jun 2016 18:53:39 -0400 Subject: [PATCH 2/3] updated README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index ac83875a..67c565a4 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ RapidCheck uses CMake and is built like any other CMake project. If your own pro This will give you both linking and include directories. +### System Installation +You can now install rapidcheck on your system. Simply add `-DRC_ENABLE_INSTALL=ON` when you run `cmake` to build the project. This will install all the include directories (include the extras - if they are enabled) and the static library that is built. + +When using the system install version with another CMake project you won't need to use `find_package(rapidcheck_)`; just make sure that the extra was enabled when you were running cmake to build the project. + ## Quick introduction ## A common first example is testing a reversal function. For such a function, double reversal should always result in the original list. In this example we will use the standard C++ `std::reverse` function: From b91b3aedbbf7595be6cb2d40ef490b819608e8fc Mon Sep 17 00:00:00 2001 From: theNerd247 Date: Sun, 12 Jun 2016 18:58:56 -0400 Subject: [PATCH 3/3] added cmake RC_ENABLE_INSTALL option --- CMakeLists.txt | 160 ++++++++++++++++--------------- extras/boost/CMakeLists.txt | 8 ++ extras/boost_test/CMakeLists.txt | 8 ++ extras/catch/CMakeLists.txt | 12 ++- extras/gmock/CMakeLists.txt | 4 + extras/gtest/CMakeLists.txt | 12 ++- 6 files changed, 123 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b2fe17d..f85ae79e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,67 +4,65 @@ enable_testing() option(RC_ENABLE_TESTS "Build RapidCheck tests" OFF) option(RC_ENABLE_EXAMPLES "Build RapidCheck examples" OFF) +option(RC_ENABLE_INSTALL "Install RadpidCheck and extras" OFF) -set(cmake_config_files - "rapidcheck-config.cmake" - ) if(MSVC) - # /bigobj - some object files become very large so we need this - # /wd4503 - truncation of decorated name, not much we can do about it so - # disable it - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /wd4503 /WX") - # /RTC* is incompatible with /O2 needed for Random.cpp to speed it up - string(REGEX REPLACE "/RTC(su|[1su])" "" - CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + # /bigobj - some object files become very large so we need this + # /wd4503 - truncation of decorated name, not much we can do about it so + # disable it + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /wd4503 /WX") + # /RTC* is incompatible with /O2 needed for Random.cpp to speed it up + string(REGEX REPLACE "/RTC(su|[1su])" "" + CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-missing-braces -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-missing-braces -std=c++11") endif() add_library(rapidcheck - src/BeforeMinimalTestCase.cpp - src/Check.cpp - src/Classify.cpp - src/GenerationFailure.cpp - src/Log.cpp - src/Random.cpp - src/Show.cpp - src/detail/Any.cpp - src/detail/Assertions.cpp - src/detail/Base64.cpp - src/detail/Configuration.cpp - src/detail/DefaultTestListener.cpp - src/detail/FrequencyMap.cpp - src/detail/ImplicitParam.cpp - src/detail/LogTestListener.cpp - src/detail/MapParser.cpp - src/detail/MulticastTestListener.cpp - src/detail/ParseException.cpp - src/detail/Platform.cpp - src/detail/Property.cpp - src/detail/PropertyContext.cpp - src/detail/ReproduceListener.cpp - src/detail/Results.cpp - src/detail/Serialization.cpp - src/detail/StringSerialization.cpp - src/detail/TestMetadata.cpp - src/detail/TestParams.cpp - src/detail/Testing.cpp - src/gen/Numeric.cpp - src/gen/Text.cpp - src/gen/detail/ExecHandler.cpp - src/gen/detail/GenerationHandler.cpp - src/gen/detail/Recipe.cpp - src/gen/detail/ScaleInteger.cpp - ) + src/BeforeMinimalTestCase.cpp + src/Check.cpp + src/Classify.cpp + src/GenerationFailure.cpp + src/Log.cpp + src/Random.cpp + src/Show.cpp + src/detail/Any.cpp + src/detail/Assertions.cpp + src/detail/Base64.cpp + src/detail/Configuration.cpp + src/detail/DefaultTestListener.cpp + src/detail/FrequencyMap.cpp + src/detail/ImplicitParam.cpp + src/detail/LogTestListener.cpp + src/detail/MapParser.cpp + src/detail/MulticastTestListener.cpp + src/detail/ParseException.cpp + src/detail/Platform.cpp + src/detail/Property.cpp + src/detail/PropertyContext.cpp + src/detail/ReproduceListener.cpp + src/detail/Results.cpp + src/detail/Serialization.cpp + src/detail/StringSerialization.cpp + src/detail/TestMetadata.cpp + src/detail/TestParams.cpp + src/detail/Testing.cpp + src/gen/Numeric.cpp + src/gen/Text.cpp + src/gen/detail/ExecHandler.cpp + src/gen/detail/GenerationHandler.cpp + src/gen/detail/Recipe.cpp + src/gen/detail/ScaleInteger.cpp + ) # Random is used a LOT so it should preferrably be really fast. if(MSVC) - set_property(SOURCE src/Random.cpp - APPEND_STRING PROPERTY COMPILE_FLAGS " /O2") + set_property(SOURCE src/Random.cpp + APPEND_STRING PROPERTY COMPILE_FLAGS " /O2") else() - set_property(SOURCE src/Random.cpp - APPEND_STRING PROPERTY COMPILE_FLAGS " -O3") + set_property(SOURCE src/Random.cpp + APPEND_STRING PROPERTY COMPILE_FLAGS " -O3") endif() target_include_directories(rapidcheck PUBLIC include) @@ -72,42 +70,50 @@ target_include_directories(rapidcheck PUBLIC include) add_subdirectory(ext) if (RC_ENABLE_TESTS) - add_subdirectory(test) + add_subdirectory(test) endif() if (RC_ENABLE_EXAMPLES) - add_subdirectory(examples) + add_subdirectory(examples) endif() add_subdirectory(extras) -# install the targets and include directories -install(TARGETS rapidcheck - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" - ) - -install(DIRECTORY "include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - ) +if(RC_ENABLE_INSTALL) -# setup the cmake config files -# the include directories to export in our cmake config file -set(CONFIG_INCLUDE_DIRS - "${CMAKE_INSTALL_PREFIX}/include" - ) + set(cmake_config_files + "rapidcheck-config.cmake" + ) -# The libraries to export in our cmake config file -set(CONFIG_LIBRARIES "rapidcheck") + # install the targets and include directories + install(TARGETS rapidcheck + ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" + ) -# generate the cmake config files -foreach(f ${cmake_config_files}) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${f}.in" - "${PROJECT_BINARY_DIR}/${f}" - @ONLY - ) + install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) - install( - FILES "${PROJECT_BINARY_DIR}/${f}" - DESTINATION "lib/cmake/rapidcheck" + # setup the cmake config files + # the include directories to export in our cmake config file + set(CONFIG_INCLUDE_DIRS + "${CMAKE_INSTALL_PREFIX}/include" ) -endforeach() + + # The libraries to export in our cmake config file + set(CONFIG_LIBRARIES "rapidcheck") + + # generate the cmake config files + foreach(f ${cmake_config_files}) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${f}.in" + "${PROJECT_BINARY_DIR}/${f}" + @ONLY + ) + + install( + FILES "${PROJECT_BINARY_DIR}/${f}" + DESTINATION "lib/cmake/rapidcheck" + ) + endforeach() + +endif() diff --git a/extras/boost/CMakeLists.txt b/extras/boost/CMakeLists.txt index d8ab1816..462bf0cb 100644 --- a/extras/boost/CMakeLists.txt +++ b/extras/boost/CMakeLists.txt @@ -9,3 +9,11 @@ endif() install(DIRECTORY "include/" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" ) + +if(RC_ENABLE_INSTALL) + + install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) + +endif() diff --git a/extras/boost_test/CMakeLists.txt b/extras/boost_test/CMakeLists.txt index bfafd168..e5628c2d 100644 --- a/extras/boost_test/CMakeLists.txt +++ b/extras/boost_test/CMakeLists.txt @@ -5,3 +5,11 @@ target_include_directories(rapidcheck_boost_test INTERFACE include) install(DIRECTORY "include/" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" ) + +if(RC_ENABLE_INSTALL) + + install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) + +endif() diff --git a/extras/catch/CMakeLists.txt b/extras/catch/CMakeLists.txt index ecb28a16..dc9280db 100644 --- a/extras/catch/CMakeLists.txt +++ b/extras/catch/CMakeLists.txt @@ -3,5 +3,13 @@ target_link_libraries(rapidcheck_catch INTERFACE rapidcheck) target_include_directories(rapidcheck_catch INTERFACE include) install(DIRECTORY "include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - ) + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) + +if(RC_ENABLE_INSTALL) + + install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) + +endif() diff --git a/extras/gmock/CMakeLists.txt b/extras/gmock/CMakeLists.txt index 9876c76f..1f46e343 100644 --- a/extras/gmock/CMakeLists.txt +++ b/extras/gmock/CMakeLists.txt @@ -6,6 +6,10 @@ if (RC_ENABLE_TESTS) add_subdirectory(test) endif() +if(RC_ENABLE_INSTALL) + install(DIRECTORY "include/" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" ) + +endif() diff --git a/extras/gtest/CMakeLists.txt b/extras/gtest/CMakeLists.txt index c66d6d1a..0b7550fc 100644 --- a/extras/gtest/CMakeLists.txt +++ b/extras/gtest/CMakeLists.txt @@ -3,5 +3,13 @@ target_link_libraries(rapidcheck_gtest INTERFACE rapidcheck) target_include_directories(rapidcheck_gtest INTERFACE include) install(DIRECTORY "include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - ) + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) + +if(RC_ENABLE_INSTALL) + + install(DIRECTORY "include/" + DESTINATION "${CMAKE_INSTALL_PREFIX}/include" + ) + +endif()