From 648ae78ac807125b3c31423daa687fe4c78f73f8 Mon Sep 17 00:00:00 2001 From: neru Date: Tue, 12 May 2026 17:50:51 -0300 Subject: [PATCH] build: check if building .h only lib (interface) or static lib --- CMakeLists.txt | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54610bc..287ba94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,10 +43,32 @@ if (SEALLIB_VFS) list(APPEND SEALLIB_SOURCES "src/lib/seallib/vfs.cpp" "src/lib/seallib/vfs.h") endif() -add_library(seallib STATIC ${SEALLIB_SOURCES}) +set(SEALLIB_HAS_SOURCES FALSE) +foreach(src ${SEALLIB_SOURCES}) + if(src MATCHES "\\.cpp$") + set(SEALLIB_HAS_SOURCES TRUE) + break() + endif() +endforeach() + +if (SEALLIB_HAS_SOURCES) + SEALLIB_HAS_SOURCES(seallib STATIC ${SEALLIB_SOURCES}) +else() + add_library(seallib INTERFACE) + target_sources(seallib INTERFACE ${SEALLIB_SOURCES}) +endif() + +if(SEALLIB_HAS_SOURCES) + set(SEALLIB_SCOPE PUBLIC) +else() + set(SEALLIB_SCOPE INTERFACE) +endif() + set_target_properties(seallib PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(seallib PUBLIC src/lib) -target_compile_features(seallib PUBLIC cxx_std_20) + +target_include_directories(seallib ${SEALLIB_SCOPE} src/lib) +target_compile_features(seallib ${SEALLIB_SCOPE} cxx_std_20) + set_target_properties(seallib PROPERTIES CXX_EXTENSIONS OFF) # ------------------------------