Skip to content

Commit 4aa8c5e

Browse files
committed
Move gtest to external/upstream, almost working...
1 parent 12eb4f5 commit 4aa8c5e

File tree

8 files changed

+61
-54
lines changed

8 files changed

+61
-54
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ include(Clang.CXX)
2929
include(autocmake_custom_color_messages)
3030
include(autocmake_python_interpreter)
3131
include(autocmake_ccache)
32+
include(numgrid)
3233
include(api)
3334
include(GNUdirs)
3435
include(include_paths)

api/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
install(FILES ${PROJECT_SOURCE_DIR}/api/numgrid.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
22

3+
message(STATUS "numgrid Fortran bindings ${BoldBlue}${ENABLE_FC_SUPPORT}${ColourReset}")
34
if(ENABLE_FC_SUPPORT)
45
add_library(numgrid_fortran OBJECT ${PROJECT_SOURCE_DIR}/api/numgrid.f90)
56
set_target_properties(numgrid_fortran PROPERTIES INCLUDE_DIRECTORIES ""
67
POSITION_INDEPENDENT_CODE 1
78
)
8-
message(STATUS "${BoldBlue}numgrid Fortran bindings ENABLED${ColourReset}")
99
endif()

cmake/autocmake.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ modules:
2323
- '%(url_root)modules/custom_color_messages.cmake'
2424
- '%(url_root)modules/python_interpreter.cmake'
2525
- '%(url_root)modules/ccache.cmake'
26+
- 'custom/numgrid.cmake'
2627
- 'custom/api.cmake'
2728
- 'custom/GNUdirs.cmake'
2829
- 'custom/include_paths.cmake'

cmake/custom/numgrid.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
option(ENABLE_UNIT_TESTS "Enable unit tests" ON)
2+
message(STATUS "Unit tests ${BoldBlue}${ENABLE_UNIT_TESTS}${ColourReset}")
3+

cmake/custom/test.cmake

+4-52
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,7 @@
1-
option(ENABLE_UNIT_TESTS "Enable unit tests" ON)
2-
message(STATUS "Enable testing: ${ENABLE_UNIT_TESTS}")
3-
41
if(ENABLE_UNIT_TESTS)
5-
include(CTest)
6-
enable_testing()
7-
8-
include(ExternalProject)
9-
10-
ExternalProject_Add(
11-
gtest
12-
PREFIX "${PROJECT_BINARY_DIR}/gtest"
13-
GIT_REPOSITORY https://github.com/google/googletest.git
14-
GIT_TAG master
15-
INSTALL_COMMAND true # currently no install command
16-
)
17-
18-
include_directories(${PROJECT_BINARY_DIR}/gtest/src/gtest/googletest/include)
19-
include_directories(${PROJECT_SOURCE_DIR}/src)
20-
21-
link_directories(${PROJECT_BINARY_DIR}/gtest/src/gtest-build/googlemock/gtest/)
22-
23-
add_executable(
24-
cpp_test
25-
test/main.cpp
26-
test/test.cpp
27-
)
28-
29-
add_dependencies(cpp_test gtest)
30-
31-
target_link_libraries(
32-
cpp_test
33-
libgtest.a
34-
numgrid
35-
pthread
36-
)
37-
38-
add_test(cpp_test ${PROJECT_BINARY_DIR}/bin/cpp_test)
39-
40-
if(ENABLE_FC_SUPPORT)
41-
add_executable(
42-
fortran_test
43-
test/test.f90
44-
)
45-
46-
add_dependencies(fortran_test gtest)
47-
48-
target_link_libraries(
49-
fortran_test
50-
numgrid
51-
)
2+
include(CTest)
3+
enable_testing()
4+
find_package(Threads REQUIRED)
525

53-
add_test(fortran_test ${PROJECT_BINARY_DIR}/bin/fortran_test)
54-
endif()
6+
add_subdirectory(test)
557
endif()

external/upstream/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
foreach(dir lebedev
2-
# gtest
2+
gtest
33
)
44
add_subdirectory(${dir})
55
endforeach()
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if(ENABLE_UNIT_TESTS)
2+
include(ExternalProject)
3+
4+
ExternalProject_Add(
5+
gtest
6+
PREFIX ${PROJECT_BINARY_DIR}/external/upstream/gtest
7+
GIT_REPOSITORY https://github.com/google/googletest.git
8+
GIT_TAG master
9+
INSTALL_COMMAND ""
10+
)
11+
endif()

test/CMakeLists.txt

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
set(gtest_ROOT ${PROJECT_BINARY_DIR}/external/upstream/gtest)
2+
set(gtest_SOURCE_DIR ${gtest_ROOT}/src/gtest/googletest)
3+
set(gtest_BINARY_DIR ${gtest_ROOT}/src/gtest-build/googlemock/gtest)
4+
5+
include_directories(${gtest_SOURCE_DIR}/include)
6+
link_directories(${gtest_BINARY_DIR})
7+
8+
add_executable(
9+
cpp_test
10+
main.cpp
11+
test.cpp
12+
)
13+
14+
add_dependencies(cpp_test gtest)
15+
16+
target_link_libraries(
17+
cpp_test
18+
numgrid
19+
libgtest.a
20+
Threads::Threads
21+
)
22+
23+
add_test(cpp_test ${PROJECT_BINARY_DIR}/bin/cpp_test)
24+
25+
if(ENABLE_FC_SUPPORT)
26+
add_executable(
27+
fortran_test
28+
test.f90
29+
)
30+
31+
add_dependencies(fortran_test gtest)
32+
33+
target_link_libraries(
34+
fortran_test
35+
numgrid
36+
)
37+
38+
add_test(fortran_test ${PROJECT_BINARY_DIR}/bin/fortran_test)
39+
endif()

0 commit comments

Comments
 (0)