leetcode/CMakeLists.txt

42 lines
813 B
CMake
Raw Normal View History

2022-03-08 07:54:17 +00:00
cmake_minimum_required(VERSION 3.14)
project(leetcode)
# GoogleTest requires at least C++11
set(CMAKE_CXX_STANDARD 11)
2022-03-21 02:22:27 +00:00
# Export compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2022-03-08 07:54:17 +00:00
include(FetchContent)
2022-03-20 03:30:06 +00:00
fetchcontent_declare(
2022-03-08 07:54:17 +00:00
googletest
2022-10-27 08:29:03 +00:00
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
2022-03-08 07:54:17 +00:00
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
2022-03-20 03:30:06 +00:00
fetchcontent_makeavailable(googletest)
2022-03-08 07:54:17 +00:00
enable_testing()
2022-03-20 03:30:06 +00:00
file(GLOB Sources src/*.cpp)
file(GLOB Tests tests/*.cpp)
2022-03-08 07:54:17 +00:00
add_executable(
2022-03-20 03:30:06 +00:00
leetcode_tests
2022-03-08 07:54:17 +00:00
${Sources}
${Tests}
)
target_link_libraries(
2022-03-20 03:30:06 +00:00
leetcode_tests
2022-03-08 07:54:17 +00:00
gtest_main
)
include(GoogleTest)
2022-03-20 03:30:06 +00:00
gtest_discover_tests(leetcode_tests)
2022-03-08 07:54:17 +00:00
2022-03-20 03:30:06 +00:00
target_include_directories(
leetcode_tests
2022-03-08 07:54:17 +00:00
PRIVATE
2022-03-20 03:30:06 +00:00
include
2022-03-08 07:54:17 +00:00
)