Skip to content

Commit

Permalink
some minor cmake tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilger26 committed Jan 16, 2025
1 parent ceafb84 commit b854600
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ __pycache__/
*.so

*.tar
Testing/
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ project("NumCpp"
LANGUAGES CXX
)

enable_testing()

message(STATUS "Building ${PROJECT_NAME} version ${VERSION_STRING}")

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

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

if(BUILD_ALL)
set(BUILD_DOCS ON)
set(BUILD_ALL_NON_PYTHON ON)
set(BUILD_TESTS ON)
endif()

if(BUILD_ALL_NON_PYTHON)
set(BUILD_DOCS ON)
set(BUILD_MULTIPLE_TEST ON)
set(BUILD_CPPCHECK_TEST ON)
set(BUILD_GTEST ON)
set(BUILD_EXAMPLE_ALL ON)
endif()

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

if (BUILD_TESTS OR BUILD_MULTIPLE_TEST OR BUILD_CPPCHECK_TEST)
enable_testing()
add_subdirectory(test)
endif()

Expand Down
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ if(BUILD_CPPCHECK_TEST)
message(STATUS "Configuring CPPCheck Test")
add_subdirectory(cppcheck)
endif()

if(BUILD_GTEST)
message(STATUS "Configuring GTest")
add_subdirectory(gtest)
endif()
9 changes: 9 additions & 0 deletions test/cppcheck/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ add_executable(${TARGET_NAME}
CppCheck.cpp
)

set_target_properties(${TARGET_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINARY_DIR}
)

target_include_directories(${TARGET_NAME} PRIVATE
${NUMCPP_INCLUDES}
)

target_link_libraries(${TARGET_NAME} PRIVATE
${ALL_INTERFACE_TARGET}
)

add_test(NAME ${TARGET_NAME}
COMMAND ${TARGET_NAME}
)
4 changes: 4 additions & 0 deletions test/cppcheck/CppCheck.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "NumCpp.hpp"

#include <iostream>

int main()
{
std::cout << "Dummy file to include all headers for CppCheck\n";

return 0;
}
11 changes: 10 additions & 1 deletion test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ add_executable(${TARGET_NAME}
test_Logger.cpp
)

set_target_properties(${TARGET_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINARY_DIR}
)

target_include_directories(${TARGET_NAME} PRIVATE
${NUMCPP_INCLUDES}
)
Expand All @@ -18,4 +23,8 @@ target_link_libraries(${TARGET_NAME} PRIVATE
)

include(GoogleTest)
gtest_discover_tests(${TARGET_NAME})
gtest_discover_tests(${TARGET_NAME})

add_test(NAME ${TARGET_NAME}
COMMAND ${TARGET_NAME}
)
4 changes: 4 additions & 0 deletions test/multiple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
target_link_libraries(${TARGET_NAME} PRIVATE
${ALL_INTERFACE_TARGET}
)

add_test(NAME ${TARGET_NAME}
COMMAND ${TARGET_NAME}
)

0 comments on commit b854600

Please sign in to comment.