diff options
| author | thecharlesblake | 2017-10-05 00:04:52 +0100 |
|---|---|---|
| committer | thecharlesblake | 2017-10-13 18:46:14 +0100 |
| commit | 33f3a5e1a340a96d2481d2ef62d12bb26fa8d1bb (patch) | |
| tree | ff4939bbb8cab80f413697dbda84724d30dfc372 /CMakeLists.txt | |
| parent | Add release as well as debug build (diff) | |
| download | metasol-33f3a5e1a340a96d2481d2ef62d12bb26fa8d1bb.tar.gz metasol-33f3a5e1a340a96d2481d2ef62d12bb26fa8d1bb.zip | |
Add GTest library to build and basic unit tests
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d70caad..0ff92bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,8 @@ set(CMAKE_CXX_STANDARD 14) # these instructions search the directory tree when cmake is # invoked and put all files that match the pattern in the variables # `sources` and `data` -file(GLOB_RECURSE sources src/main/*.cpp src/main/*.h) -file(GLOB_RECURSE sources_test src/test/*.cpp) -file(GLOB_RECURSE data resources/*) +set(sources src/main/main.cpp) +set(sources_test src/test/all_tests.cpp src/test/main_test.cpp) ############################################################################### ## conan.io setup ############################################################# @@ -32,7 +31,7 @@ endif() ############################################################################### # add the data to the target, so it becomes visible in some IDE -add_executable(solitaire_pip ${sources} ${data}) +add_executable(solitaire_pip ${sources}) # just for example add some compiler flags target_compile_options(solitaire_pip PUBLIC -std=c++1y -Wall -Wfloat-conversion) @@ -48,6 +47,23 @@ target_link_libraries(solitaire_pip ${CONAN_LIBS}) file(COPY ${data} DESTINATION resources) ############################################################################### +## testing #################################################################### +############################################################################### + +add_executable(unit_tests ${sources_test}) + +# this allows us to use our executable as a link library +# therefore we can inherit all compiler options and library dependencies +set_target_properties(solitaire_pip PROPERTIES ENABLE_EXPORTS on) + +target_link_libraries(unit_tests ${CONAN_LIBS} solitaire_pip) + +ENABLE_TESTING() +ADD_TEST(NAME unit_tests + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin + COMMAND unit_tests) + +############################################################################### ## packaging ################################################################## ############################################################################### |
