From 56155e878ab77233f49188f443020e3c8e077a1c Mon Sep 17 00:00:00 2001 From: limuy Date: Sun, 26 Nov 2023 09:27:25 +0800 Subject: [PATCH] fix cmake --- CMakeLists.txt | 61 ++++++++++++++++++++++++++--------------- language/CMakeLists.txt | 20 -------------- 2 files changed, 39 insertions(+), 42 deletions(-) delete mode 100644 language/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 47ada9f3..d0d407cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,30 +12,28 @@ link_directories("${PROJECT_SOURCE_DIR}/bin") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") -#add_subdirectory(language) - -#add_compile_definitions("UNITTEST") -#file(GLOB_RECURSE TEST_SOURCES "tests/unittest/*.cpp") -#file(GLOB_RECURSE TEST_MODULE_SOURCES "tests/unittest/*.cppm") -#add_library(testmodulefiles) -# -#target_sources(testmodulefiles -# PUBLIC -# FILE_SET CXX_MODULES FILES -# ${SOURCES} -# ${LANGUAGE_SOURCES} -# ${TEST_MODULE_SOURCES} -#) -# -#add_executable(unittest -# ${CPP_SOURCES} -# ${TEST_SOURCES} -#) -#target_link_libraries(unittest testmodulefiles language) - add_subdirectory("cmake_third_party/googletest") include_directories("cmake_third_party/googletest/googletest/include") +add_library(language_module) +target_sources(language_module + PUBLIC + FILE_SET CXX_MODULES FILES + language/language.cppm +) + +message("${LANGUAGE_SOURCES}") + +add_library(Chinese language/chinese.cpp) + +add_library(English language/english.cpp) + +add_library(language language/english.cpp) + +target_link_libraries(Chinese language_module) +target_link_libraries(English language_module) +target_link_libraries(language language_module) + file(GLOB_RECURSE CPPMSOURCES "*.cppm") file(GLOB_RECURSE CPP_SOURCES "src/*.cpp") @@ -52,4 +50,23 @@ target_sources(foo add_executable(Trc ${CPP_SOURCES}) target_link_libraries(Trc foo) -target_link_libraries(Trc "language") +target_link_libraries(Trc language) + + +file(GLOB_RECURSE TEST_SOURCES "tests/unittest/*.cpp") +file(GLOB_RECURSE TEST_MODULE_SOURCES "tests/unittest/*.cppm") +add_library(testmodulefiles) + +target_sources(testmodulefiles + PUBLIC + FILE_SET CXX_MODULES FILES + ${CPPMSOURCES} + ${TEST_MODULE_SOURCES} +) + +add_executable(unittest + ${CPP_SOURCES} + ${TEST_SOURCES} +) +target_compile_definitions(unittest PRIVATE "UNITTEST") +target_link_libraries(unittest testmodulefiles language gtest) diff --git a/language/CMakeLists.txt b/language/CMakeLists.txt deleted file mode 100644 index b4fd09b3..00000000 --- a/language/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -file(GLOB_RECURSE LANGUAGE_SOURCES "*.cppm") - -add_library(language_module) -target_sources(language_module - PUBLIC - FILE_SET CXX_MODULES FILES - ${LANGUAGE_SOURCES} -) - -message("${LANGUAGE_SOURCES}") - -add_library(Chinese chinese.cpp) - -add_library(English english.cpp) - -add_library(language english.cpp) - -target_link_libraries(Chinese language_module) -target_link_libraries(English language_module) -target_link_libraries(language language_module)