From f4136569125fb3b20db77591df4ce47ec731cf00 Mon Sep 17 00:00:00 2001 From: Rick Altherr Date: Tue, 9 Jan 2018 12:26:14 -0800 Subject: [PATCH 1/3] Disable tests by default No need to spend time building all the tests unless you specifically want them. To build them, run 'cmake -DPRJXRAY_BUILD_TESTING=ON ..' in the build directory. Signed-off-by: Rick Altherr --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe8e0ee2..4a0bd664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5.0) project(prjxray) -option(PRJXRAY_BUILD_TESTING "" ON) +option(PRJXRAY_BUILD_TESTING "" OFF) set(CMAKE_CXX_STANDARD 14) add_compile_options(-Wall -Werror) From 0910ac07a2dc13036b0e6e36cd8ad753c2d2b487 Mon Sep 17 00:00:00 2001 From: Rick Altherr Date: Tue, 9 Jan 2018 12:27:14 -0800 Subject: [PATCH 2/3] Use CMake build types to set optimization level CMake has reasonable defaults for Debug and Release builds but the build type isn't specified by default. That led to me adding explicit flags. Remove those flags and default to using Release builds. Signed-off-by: Rick Altherr --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a0bd664..13645ab1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,18 +3,20 @@ cmake_minimum_required(VERSION 3.5.0) project(prjxray) option(PRJXRAY_BUILD_TESTING "" OFF) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE) +endif() + set(CMAKE_CXX_STANDARD 14) add_compile_options(-Wall -Werror) # Hack for missing option in cctz option(BUILD_TESTING "" OFF) - if(PRJXRAY_BUILD_TESTING) enable_testing() - add_compile_options(-O0 -g) -else() - add_compile_options(-O3) endif() add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL) From 02d28f2920d9e88445bbfa5885dad91e7e049e8d Mon Sep 17 00:00:00 2001 From: Rick Altherr Date: Fri, 12 Jan 2018 10:33:33 -0800 Subject: [PATCH 3/3] Document how to enable test and build with debug info Signed-off-by: Rick Altherr --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 4f1c3cc1..44542944 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,22 @@ Creating HTML documentation: cd fuzzers/010-lutinit make -j$(nproc) run +Tests are not built by default. Setting the PRJXRAY\_BUILD\_TESTING option to +ON when running cmake will include them: + + cmake -DPRJXRAY_BUILD_TESTING=ON .. + make + +The default C++ build configuration is for releases (optimizations enabled, no +debug info). A build configuration for debugging (no optimizations, debug info) +can be chosen via the CMAKE\_BUILD\_TYPE option: + + cmake -DCMAKE_BUILD_TYPE=Debug .. + make + +The options to build tests and use a debug build configuration are independent +to allow testing that optimizations do not cause bugs. The build configuration +and build tests options may be combined to allow all permutations. # Process