Skip to content

Commit c8bb6c8

Browse files
committed
cmake: fix setup_compiler by wrapping Compiler.cmake in a function
CMakeLists.txt calls setup_compiler(TARGET) after including cmake/Compiler.cmake, but Compiler.cmake only contained flat cmake code using ${PROJECT_NAME} directly — the setup_compiler function was never defined, causing: CMake Error: Unknown CMake command "setup_compiler" Fix: wrap the content of cmake/Compiler.cmake in function(setup_compiler TARGET) and replace ${PROJECT_NAME} references with ${TARGET} so the include/call pattern works correctly.
1 parent e75e7db commit c8bb6c8

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

cmake/Compiler.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
set_target_properties(${PROJECT_NAME}
1+
function(setup_compiler TARGET)
2+
set_target_properties(${TARGET}
23
PROPERTIES
34
EXPORT_COMPILE_COMMANDS ON
45
CXX_STANDARD_REQUIRED YES
56
CXX_EXTENSIONS NO
67
CXX_STANDARD 17
78
)
89

9-
target_compile_features(${PROJECT_NAME}
10+
target_compile_features(${TARGET}
1011
PRIVATE
1112
cxx_std_17
1213
)
@@ -54,14 +55,15 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
5455
)
5556
endif()
5657

57-
target_compile_options(${PROJECT_NAME}
58+
target_compile_options(${TARGET}
5859
PRIVATE
5960
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_COMPILE_OPTIONS}>
6061
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${NOT_MSVC_COMPILE_OPTIONS}>
6162
)
6263

63-
target_link_options(${PROJECT_NAME}
64+
target_link_options(${TARGET}
6465
PUBLIC
6566
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_LINK_OPTIONS}>
6667
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${NOT_MSVC_LINK_OPTIONS}>
6768
)
69+
endfunction()

0 commit comments

Comments
 (0)