Skip to content

Commit 5f135fe

Browse files
committed
fix(template): prevent duplicate target/export in umbrella build
- add global re-entry guard to avoid multiple inclusion of template module - ensure template target is defined only once - prevent duplicate install(EXPORT VixTargets) entries - fix CMake error: target 'template' exported more than once This stabilizes umbrella packaging and makes install(EXPORT) deterministic.
1 parent caaafa7 commit 5f135fe

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
cmake_minimum_required(VERSION 3.20)
22

3+
# ============================================================================
4+
# Re-entry guard
5+
# Prevent the template module from being configured/exported twice
6+
# ============================================================================
7+
8+
get_property(_VIX_TEMPLATE_MODULE_ALREADY_INCLUDED GLOBAL PROPERTY VIX_TEMPLATE_MODULE_ALREADY_INCLUDED)
9+
if(_VIX_TEMPLATE_MODULE_ALREADY_INCLUDED)
10+
return()
11+
endif()
12+
set_property(GLOBAL PROPERTY VIX_TEMPLATE_MODULE_ALREADY_INCLUDED TRUE)
13+
314
project(template
415
VERSION 0.1.0
516
DESCRIPTION "Template rendering engine for Vix.cpp"
@@ -48,7 +59,7 @@ include(GNUInstallDirs)
4859
# Library
4960
# ============================================================================
5061

51-
add_library(template
62+
set(TEMPLATE_SOURCES
5263
src/Builtins.cpp
5364
src/Cache.cpp
5465
src/Compiler.cpp
@@ -68,7 +79,11 @@ add_library(template
6879
src/Optimizer.cpp
6980
)
7081

71-
add_library(vix::template ALIAS template)
82+
add_library(template STATIC ${TEMPLATE_SOURCES})
83+
84+
if(NOT TARGET vix::template)
85+
add_library(vix::template ALIAS template)
86+
endif()
7287

7388
target_include_directories(template
7489
PUBLIC

0 commit comments

Comments
 (0)