Skip to content

Commit b854600

Browse files
committed
some minor cmake tweaks
1 parent ceafb84 commit b854600

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ __pycache__/
2222
*.so
2323

2424
*.tar
25+
Testing/

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ project("NumCpp"
1313
LANGUAGES CXX
1414
)
1515

16-
enable_testing()
17-
1816
message(STATUS "Building ${PROJECT_NAME} version ${VERSION_STRING}")
1917

2018
if(NOT CMAKE_BUILD_TYPE)
@@ -30,10 +28,12 @@ message(STATUS "Compiling with C++ standard: ${CMAKE_CXX_STANDARD}")
3028
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # works
3129

3230
option(BUILD_ALL "Build All targets" OFF)
31+
option(BUILD_ALL_NON_PYTHON "Build All targets except the python bindings for pytest" OFF)
3332
option(BUILD_DOCS "Build the doxygen documentation" OFF)
3433
option(BUILD_TESTS "Build the unit tests" OFF)
3534
option(BUILD_MULTIPLE_TEST "Build the multiple translation unit test" OFF)
3635
option(BUILD_CPPCHECK_TEST "Build the cppcheck test" OFF)
36+
option(BUILD_GTEST "Build the gtest tests" OFF)
3737
option(BUILD_EXAMPLE_ALL "Build all of the examples" OFF)
3838
option(BUILD_EXAMPLE_GAUSS_NEWTON_NLLS "Build the Gauss-Newton NLLS example" OFF)
3939
option(BUILD_EXAMPLE_INTERFACE_WITH_EIGEN "Build the Interface with Eigen example" OFF)
@@ -44,10 +44,15 @@ option(NUMCPP_NO_USE_BOOST "Don't use the boost libraries" OFF)
4444
option(NUMCPP_USE_MULTITHREAD "Enable multithreading" OFF)
4545

4646
if(BUILD_ALL)
47-
set(BUILD_DOCS ON)
47+
set(BUILD_ALL_NON_PYTHON ON)
4848
set(BUILD_TESTS ON)
49+
endif()
50+
51+
if(BUILD_ALL_NON_PYTHON)
52+
set(BUILD_DOCS ON)
4953
set(BUILD_MULTIPLE_TEST ON)
5054
set(BUILD_CPPCHECK_TEST ON)
55+
set(BUILD_GTEST ON)
5156
set(BUILD_EXAMPLE_ALL ON)
5257
endif()
5358

@@ -134,6 +139,7 @@ get_filename_component(NUMCPP_INCLUDES ./include ABSOLUTE)
134139
set(OUTPUT_BINARY_DIR ${PROJECT_SOURCE_DIR}/bin/$<0:>)
135140

136141
if (BUILD_TESTS OR BUILD_MULTIPLE_TEST OR BUILD_CPPCHECK_TEST)
142+
enable_testing()
137143
add_subdirectory(test)
138144
endif()
139145

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ if(BUILD_CPPCHECK_TEST)
1313
message(STATUS "Configuring CPPCheck Test")
1414
add_subdirectory(cppcheck)
1515
endif()
16+
17+
if(BUILD_GTEST)
18+
message(STATUS "Configuring GTest")
19+
add_subdirectory(gtest)
20+
endif()

test/cppcheck/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ add_executable(${TARGET_NAME}
44
CppCheck.cpp
55
)
66

7+
set_target_properties(${TARGET_NAME}
8+
PROPERTIES
9+
RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINARY_DIR}
10+
)
11+
712
target_include_directories(${TARGET_NAME} PRIVATE
813
${NUMCPP_INCLUDES}
914
)
1015

1116
target_link_libraries(${TARGET_NAME} PRIVATE
1217
${ALL_INTERFACE_TARGET}
1318
)
19+
20+
add_test(NAME ${TARGET_NAME}
21+
COMMAND ${TARGET_NAME}
22+
)

test/cppcheck/CppCheck.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include "NumCpp.hpp"
22

3+
#include <iostream>
4+
35
int main()
46
{
7+
std::cout << "Dummy file to include all headers for CppCheck\n";
8+
59
return 0;
610
}

test/gtest/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ add_executable(${TARGET_NAME}
66
test_Logger.cpp
77
)
88

9+
set_target_properties(${TARGET_NAME}
10+
PROPERTIES
11+
RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINARY_DIR}
12+
)
13+
914
target_include_directories(${TARGET_NAME} PRIVATE
1015
${NUMCPP_INCLUDES}
1116
)
@@ -18,4 +23,8 @@ target_link_libraries(${TARGET_NAME} PRIVATE
1823
)
1924

2025
include(GoogleTest)
21-
gtest_discover_tests(${TARGET_NAME})
26+
gtest_discover_tests(${TARGET_NAME})
27+
28+
add_test(NAME ${TARGET_NAME}
29+
COMMAND ${TARGET_NAME}
30+
)

test/multiple/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
1818
target_link_libraries(${TARGET_NAME} PRIVATE
1919
${ALL_INTERFACE_TARGET}
2020
)
21+
22+
add_test(NAME ${TARGET_NAME}
23+
COMMAND ${TARGET_NAME}
24+
)

0 commit comments

Comments
 (0)