From eccdd102d4fb31e483b9b3bbaeb7841b6d223809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20St=C3=B6cker?= Date: Thu, 24 Oct 2024 11:54:36 +0200 Subject: [PATCH] add STATIC_LIB option (#343) add RAYX_STATIC_LIB option --- CMakeLists.txt | 2 ++ Intern/rayx-core/CMakeLists.txt | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f19affa7..a0946801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ set(CMAKE_CUDA_STANDARD_REQUIRED ON) option(WERROR "add -Werror option" "NO") # inactive per default option(RAYX_ENABLE_CUDA "This option enables the search for CUDA. Project will be compiled without cuda if not found." ON) option(RAYX_REQUIRE_CUDA "If option 'RAYX_ENABLE_CUDA' is ON, this option will add the requirement that cuda must be found." OFF) +option(RAYX_STATIC_LIB "This option builds 'rayx-core' as a static library." OFF) + # ------------------ # ---- Code Coverage ---- diff --git a/Intern/rayx-core/CMakeLists.txt b/Intern/rayx-core/CMakeLists.txt index c4db295c..f08b4500 100644 --- a/Intern/rayx-core/CMakeLists.txt +++ b/Intern/rayx-core/CMakeLists.txt @@ -57,7 +57,14 @@ file(GLOB_RECURSE ALPAKA_SOURCE ${PROJECT_SOURCE_DIR}/src/Shader/*.cpp ${PROJECT_SOURCE_DIR}/src/Tracer/*.cpp ) -add_library(${PROJECT_NAME} SHARED ${SOURCE}) + +if(RAYX_STATIC_LIB) + add_library(${PROJECT_NAME} STATIC ${SOURCE}) + set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +else() + add_library(${PROJECT_NAME} SHARED ${SOURCE}) +endif() + alpaka_target(${PROJECT_NAME}) alpaka_source(${ALPAKA_SOURCE}) # -----------------