initial commit
This commit is contained in:
33
cplusplus/geminitutorial/tutorial1/CMakeLists.txt
Normal file
33
cplusplus/geminitutorial/tutorial1/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(Tutorial1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Find dependencies
|
||||
find_package(spdlog CONFIG REQUIRED)
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
|
||||
# Create a library for our application code
|
||||
# This allows us to share the code between the main app and the tests
|
||||
add_library(MyLib src/calculator.cpp src/calculator.h)
|
||||
target_include_directories(MyLib PUBLIC src)
|
||||
|
||||
# Define our main executable
|
||||
add_executable(App src/main.cpp)
|
||||
|
||||
# Link our App against spdlog and our library
|
||||
target_link_libraries(App PRIVATE spdlog::spdlog MyLib)
|
||||
|
||||
# Enable testing with CTest (CMake's testing framework)
|
||||
enable_testing()
|
||||
|
||||
# Define the test executable
|
||||
add_executable(RunTests test/test_calculator.cpp)
|
||||
|
||||
# Link our test executable against GTest and our library
|
||||
target_link_libraries(RunTests PRIVATE GTest::gtest_main MyLib)
|
||||
|
||||
# Add the test to CTest
|
||||
include(GoogleTest)
|
||||
gtest_add_tests(TARGET RunTests)
|
||||
Reference in New Issue
Block a user