From 745a296a577a9e408e2af798ab9b8eda1cc4d821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 23 Sep 2020 22:39:18 +0200 Subject: [PATCH 1/2] cmake: Add fizzy::fizzy-internal INTERFACE library The fizzy::fizzy-internal links fizzy::fizzy library with access to internal headers. --- lib/fizzy/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/fizzy/CMakeLists.txt b/lib/fizzy/CMakeLists.txt index 09c9a8cad..e77ac1cbb 100644 --- a/lib/fizzy/CMakeLists.txt +++ b/lib/fizzy/CMakeLists.txt @@ -36,3 +36,9 @@ target_sources( utf8.hpp value.hpp ) + +# The fizzy::fizzy-internal links fizzy::fizzy library with access to internal headers. +add_library(fizzy-internal INTERFACE) +add_library(fizzy::fizzy-internal ALIAS fizzy-internal) +target_link_libraries(fizzy-internal INTERFACE fizzy::fizzy) +target_include_directories(fizzy-internal INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) From 2ec9d1a729b00d82c83cc4611442753c03c9a4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 23 Sep 2020 22:51:49 +0200 Subject: [PATCH 2/2] cmake: Use fizzy::fizzy-internal Instead of including the directory with internal headers directly. --- test/CMakeLists.txt | 2 -- test/bench/CMakeLists.txt | 3 +-- test/bench_internal/CMakeLists.txt | 3 +-- test/fuzzer/CMakeLists.txt | 3 +-- test/spectests/CMakeLists.txt | 3 +-- test/unittests/CMakeLists.txt | 2 +- test/utils/CMakeLists.txt | 4 ++-- 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d09827f28..8fc5e9f91 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,8 +22,6 @@ if(HUNTER_ENABLED) endif() find_package(GTest REQUIRED) -set(fizzy_include_dir ${PROJECT_SOURCE_DIR}/lib/fizzy) - add_subdirectory(utils) add_subdirectory(bench) add_subdirectory(bench_internal) diff --git a/test/bench/CMakeLists.txt b/test/bench/CMakeLists.txt index 3783f4bcd..31aaed54a 100644 --- a/test/bench/CMakeLists.txt +++ b/test/bench/CMakeLists.txt @@ -4,8 +4,7 @@ add_executable(fizzy-bench bench.cpp) target_compile_features(fizzy-bench PRIVATE cxx_std_17) -target_link_libraries(fizzy-bench PRIVATE fizzy::fizzy fizzy::test-utils benchmark::benchmark) -target_include_directories(fizzy-bench PRIVATE ${fizzy_include_dir}) +target_link_libraries(fizzy-bench PRIVATE fizzy::fizzy-internal fizzy::test-utils benchmark::benchmark) if(UNIX AND NOT APPLE) # For libstdc++ up to version 8 (included) this is needed for proper support. diff --git a/test/bench_internal/CMakeLists.txt b/test/bench_internal/CMakeLists.txt index 05133b168..bf4d24ea9 100644 --- a/test/bench_internal/CMakeLists.txt +++ b/test/bench_internal/CMakeLists.txt @@ -12,5 +12,4 @@ target_sources(fizzy-bench-internal PRIVATE parser_benchmarks.cpp ) -target_link_libraries(fizzy-bench-internal PRIVATE fizzy::fizzy fizzy::test-utils benchmark::benchmark_main) -target_include_directories(fizzy-bench-internal PRIVATE ${fizzy_include_dir}) +target_link_libraries(fizzy-bench-internal PRIVATE fizzy::fizzy-internal fizzy::test-utils benchmark::benchmark_main) diff --git a/test/fuzzer/CMakeLists.txt b/test/fuzzer/CMakeLists.txt index 254a77bc8..a5570b54b 100644 --- a/test/fuzzer/CMakeLists.txt +++ b/test/fuzzer/CMakeLists.txt @@ -4,5 +4,4 @@ add_executable(fizzy-fuzz-parser parser_fuzzer.cpp) target_link_options(fizzy-fuzz-parser PRIVATE -fsanitize=fuzzer) -target_link_libraries(fizzy-fuzz-parser PRIVATE fizzy::fizzy) -target_include_directories(fizzy-fuzz-parser PRIVATE ${fizzy_include_dir}) +target_link_libraries(fizzy-fuzz-parser PRIVATE fizzy::fizzy-internal) diff --git a/test/spectests/CMakeLists.txt b/test/spectests/CMakeLists.txt index 34457f094..3ffb44e4d 100644 --- a/test/spectests/CMakeLists.txt +++ b/test/spectests/CMakeLists.txt @@ -9,8 +9,7 @@ find_package(nlohmann_json REQUIRED) add_executable(fizzy-spectests spectests.cpp) target_compile_features(fizzy-spectests PRIVATE cxx_std_17) -target_link_libraries(fizzy-spectests PRIVATE fizzy::fizzy fizzy::test-utils nlohmann_json::nlohmann_json) -target_include_directories(fizzy-spectests PRIVATE ${fizzy_include_dir}) +target_link_libraries(fizzy-spectests PRIVATE fizzy::fizzy-internal fizzy::test-utils nlohmann_json::nlohmann_json) if(UNIX AND NOT APPLE) # For libstdc++ up to version 8 (included) this is needed for proper support. diff --git a/test/unittests/CMakeLists.txt b/test/unittests/CMakeLists.txt index ef16c4617..bccce46eb 100644 --- a/test/unittests/CMakeLists.txt +++ b/test/unittests/CMakeLists.txt @@ -5,7 +5,7 @@ include(GoogleTest) add_executable(fizzy-unittests) -target_link_libraries(fizzy-unittests PRIVATE fizzy::fizzy fizzy::test-utils GTest::gtest_main GTest::gmock) +target_link_libraries(fizzy-unittests PRIVATE fizzy::fizzy-internal fizzy::test-utils GTest::gtest_main GTest::gmock) target_sources( fizzy-unittests PRIVATE diff --git a/test/utils/CMakeLists.txt b/test/utils/CMakeLists.txt index f03d76ba6..16a3afc40 100644 --- a/test/utils/CMakeLists.txt +++ b/test/utils/CMakeLists.txt @@ -28,5 +28,5 @@ target_sources( ) target_compile_features(test-utils PUBLIC cxx_std_17) -target_include_directories(test-utils PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/lib/fizzy) -target_link_libraries(test-utils PRIVATE fizzy::fizzy wabt::wabt wasm3::wasm3 GTest::gtest) +target_include_directories(test-utils PUBLIC ${PROJECT_SOURCE_DIR}) +target_link_libraries(test-utils PUBLIC fizzy::fizzy-internal PRIVATE wabt::wabt wasm3::wasm3 GTest::gtest)