Last active
September 5, 2024 13:22
-
-
Save mtavkhelidze/1ef2b11ddce224da4b586494d6c65335 to your computer and use it in GitHub Desktop.
Template CMakeLists with GoogleTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.30) | |
project(project_cpp VERSION 0.1.0) | |
set(CMAKE_CXX_STANDARD 20) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
SET(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror" CACHE PATH "" FORCE) | |
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/lib) | |
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/lib) | |
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/bin) | |
include(FetchContent) | |
execute_process(COMMAND ${CMAKE_COMMAND} -E echo_append " -- Fetching GoogleTest...") | |
FetchContent_Declare( | |
googletest | |
GIT_REPOSITORY https://github.com/google/googletest.git | |
GIT_TAG v1.15.2 | |
) | |
execute_process(COMMAND ${CMAKE_COMMAND} -E echo " done") | |
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | |
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) | |
set(BUILD_GTEST ON CACHE BOOL "" FORCE) | |
FetchContent_MakeAvailable(googletest) | |
include(GoogleTest) | |
enable_testing() | |
add_subdirectory(src) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment