diff options
-rw-r--r-- | CMakeLists.txt | 34 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | test/CMakeLists.txt | 22 |
3 files changed, 30 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 348393e..19e92ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.14) -project(systemc_utils CXX) +project(systemc_playground CXX) + +set(SRC ${CMAKE_CURRENT_SOURCE_DIR}/src) set (CMAKE_PREFIX_PATH $ENV{SYSTEMC_HOME}) find_package(SystemCLanguage CONFIG REQUIRED) @@ -8,33 +10,11 @@ find_package(SystemCLanguage CONFIG REQUIRED) set (CMAKE_CXX_STANDARD ${SystemC_CXX_STANDARD} CACHE STRING "C++ standard to build all targets.") foreach (X IN ITEMS event sc_export sc_export2 minimal_socket browse lt_bus) - add_executable(${X} src/${X}.cc) - target_include_directories(${X} PRIVATE src) + add_executable(${X} ${SRC}/${X}.cc) + target_include_directories(${X} PRIVATE ${SRC}) target_compile_options(${X} PRIVATE -Wall -Wextra) target_link_libraries(${X} SystemC::systemc) endforeach() -# -- TESTING ------------------------------------------------------------------- - -# Fetch googletest. -# https://google.github.io/googletest/quickstart-cmake.html#set-up-a-project -include(FetchContent) -FetchContent_Declare( - googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip -) -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(googletest) - -# Generate CTestTestfile.cmake. -enable_testing() -# Include gtest_discover_tests macro. -include(GoogleTest) - -foreach(T IN ITEMS lt_bus) - set(TGT test-${T}) - add_executable(${TGT} test/${T}.cc) - target_include_directories(${TGT} PRIVATE src) - target_compile_options(${TGT} PRIVATE -Wall -Wextra) - target_link_libraries(${TGT} GTest::gmock_main SystemC::systemc) - gtest_discover_tests(${TGT}) -endforeach() +# Include tests. +add_subdirectory(test) @@ -23,7 +23,7 @@ run: build done test: build - cd BUILD/PLAYGROUND && ctest --output-on-failure + cd BUILD/PLAYGROUND/test && ctest --output-on-failure BUILD/PLAYGROUND/CMakeCache.txt: CMakeLists.txt cmake -B BUILD/PLAYGROUND $@ -S . \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..b67735a --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,22 @@ +# Fetch googletest. +# https://google.github.io/googletest/quickstart-cmake.html#set-up-a-project +include(FetchContent) +FetchContent_Declare( + googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip +) +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +# Generate CTestTestfile.cmake. +enable_testing() +# Include gtest_discover_tests macro. +include(GoogleTest) + +foreach(T IN ITEMS lt_bus) + set(TGT test-${T}) + add_executable(${TGT} ${T}.cc) + target_include_directories(${TGT} PRIVATE ${SRC}) + target_compile_options(${TGT} PRIVATE -Wall -Wextra) + target_link_libraries(${TGT} GTest::gmock_main SystemC::systemc) + gtest_discover_tests(${TGT}) +endforeach() |