From 595cd8e54e57fae5dbef08ef82d09c12a81b131d Mon Sep 17 00:00:00 2001 From: Yu SuiXian <47711102+GengGode@users.noreply.github.com> Date: Fri, 8 Mar 2024 13:52:55 +0800 Subject: [PATCH] =?UTF-8?q?build:=20cmake=E6=B7=BB=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=A4=B4=E6=96=87=E4=BB=B6=E7=9B=AE=E6=A0=87=20(#49)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00a2b47..b98b506 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,13 +28,16 @@ file(GLOB_RECURSE json_headers include/*.hpp ) +add_library(meojson INTERFACE ${json_headers}) + if (BUILD_SAMPLE) file(GLOB sample_src sample/*.cpp sample/*.h sample/*.hpp ) - add_executable(sample ${sample_src} ${json_headers}) + add_executable(sample ${sample_src}) + target_link_libraries(sample meojson) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${json_headers}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${sample_src}) @@ -46,7 +49,8 @@ if (BUILD_TESTING) test/*.h test/*.hpp ) - add_executable(testing ${testing_src} ${json_headers}) + add_executable(testing ${testing_src}) + target_link_libraries(testing meojson) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${json_headers}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${testing_src}) @@ -59,7 +63,9 @@ if (BUILD_BENCHMARK) benchmark/*.h benchmark/*.hpp ) - add_executable(benchmark ${benchmark_src} ${json_headers}) + add_executable(benchmark ${benchmark_src}) + target_link_libraries(benchmark meojson) + source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${json_headers}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${benchmark_src})