Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiser-Yang committed May 7, 2024
1 parent 12ab92d commit 327e731
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ else()
add_library(mca STATIC ${mca_SOURCE})
endif()

find_package(Threads REQUIRED)
target_link_libraries(mca PUBLIC Threads::Threads)
# when built as a sub directory, epxort mca_LINK_LIB
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(mca_LINK_LIB ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE)
endif()

target_include_directories(mca PUBLIC ${PROJECT_SOURCE_DIR}/src/include)

find_program(CLANG_TIDY_EXE NAMES clang-tidy)
Expand Down
15 changes: 14 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.14)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(unit_test)
message(FATAL_ERROR "You can not build this project as a main project")
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(CMAKE_CXX_EXTENSIONS off)
Expand Down Expand Up @@ -29,7 +34,15 @@ target_link_libraries(
GTest::gtest_main
mca)

gtest_discover_tests(${PROJECT_NAME}_unit_test WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
if (WIN32 AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
message("${CMAKE_BINARY_DIR}/${LIBRARY_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}")
gtest_discover_tests(
${PROJECT_NAME}_unit_test
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}/${LIBRARY_OUTPUT_PATH}/${CMAKE_BUILD_TYPE})
else()
gtest_discover_tests(${PROJECT_NAME}_unit_test)
endif()

find_program(CLANG_TIDY_EXE NAMES clang-tidy)
if (CLANG_TIDY_EXE)
Expand Down

0 comments on commit 327e731

Please sign in to comment.