From d088f809715ed8f89d5a36b9868438a4a88ba9d0 Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 22 Nov 2023 11:29:59 +0100 Subject: [PATCH] Fix: Prefix CMake macros to avoid naming collisions --- CMakeLists.txt | 8 ++++---- cmake/add_source_directory.cmake | 2 +- cmake/compiler_flags.cmake | 4 ++-- examples/gl_viewer/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 250ee848f..975fd3237 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,8 +56,8 @@ if (FASTGLTF_DOWNLOAD_SIMDJSON) add_library(fastgltf_simdjson ${SIMDJSON_HEADER_FILE} ${SIMDJSON_SOURCE_FILE}) target_compile_features(fastgltf_simdjson PRIVATE cxx_std_17) target_include_directories(fastgltf_simdjson PUBLIC $ $) - compiler_flags(fastgltf_simdjson) - enable_debug_inlining(fastgltf_simdjson) + fastgltf_compiler_flags(fastgltf_simdjson) + fastgltf_enable_debug_inlining(fastgltf_simdjson) install( FILES deps/simdjson/simdjson.h @@ -87,8 +87,8 @@ add_library(fastgltf "include/fastgltf/base64.hpp" "include/fastgltf/glm_element_traits.hpp" "include/fastgltf/parser.hpp" "include/fastgltf/tools.hpp" "include/fastgltf/types.hpp" "include/fastgltf/util.hpp") add_library(fastgltf::fastgltf ALIAS fastgltf) -compiler_flags(fastgltf) -enable_debug_inlining(fastgltf) +fastgltf_compiler_flags(fastgltf) +fastgltf_enable_debug_inlining(fastgltf) target_compile_features(fastgltf PUBLIC cxx_std_17) target_include_directories(fastgltf PUBLIC $ $) diff --git a/cmake/add_source_directory.cmake b/cmake/add_source_directory.cmake index 67e0998b2..3865d672a 100644 --- a/cmake/add_source_directory.cmake +++ b/cmake/add_source_directory.cmake @@ -1,6 +1,6 @@ # This will search for all files with .c, .cpp, .h, .hpp extensions in the given folder directory but no subdirectories and add them as # sources to the target. -function(add_source_directory) +function(fastgltf_add_source_directory) cmake_parse_arguments(PARAM "" "TARGET;FOLDER" "CONDITIONAL" ${ARGN}) # Generic C/C++/ObjC file extensions diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake index 5e1b82c10..b6cf7f760 100644 --- a/cmake/compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -1,4 +1,4 @@ -macro(compiler_flags TARGET) +macro(fastgltf_compiler_flags TARGET) if (NOT ${TARGET} STREQUAL "" AND TARGET ${TARGET}) # Note that simdjson automatically figures out which SIMD intrinsics to use at runtime based on # cpuid, meaning no architecture flags or other compile flags need to be passed. @@ -20,7 +20,7 @@ macro(compiler_flags TARGET) endif() endmacro() -macro(enable_debug_inlining TARGET) +macro(fastgltf_enable_debug_inlining TARGET) if (NOT ${TARGET} STREQUAL "" AND TARGET ${TARGET}) if (MSVC) target_compile_options(${TARGET} PRIVATE $<$:/Ob2>) diff --git a/examples/gl_viewer/CMakeLists.txt b/examples/gl_viewer/CMakeLists.txt index 9e4f840a2..b284bc1e3 100644 --- a/examples/gl_viewer/CMakeLists.txt +++ b/examples/gl_viewer/CMakeLists.txt @@ -3,4 +3,4 @@ target_compile_features(fastgltf_gl_viewer PUBLIC cxx_std_17) target_link_libraries(fastgltf_gl_viewer PRIVATE fastgltf fg_glad_gl46) target_link_libraries(fastgltf_gl_viewer PRIVATE glfw::glfw glm::glm stb) -add_source_directory(TARGET fastgltf_gl_viewer FOLDER ".") +fastgltf_add_source_directory(TARGET fastgltf_gl_viewer FOLDER ".") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a7d541afa..09086a3d5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,7 @@ add_executable(fastgltf_tests EXCLUDE_FROM_ALL target_compile_features(fastgltf_tests PRIVATE cxx_std_17) target_link_libraries(fastgltf_tests PRIVATE fastgltf fastgltf_simdjson) target_link_libraries(fastgltf_tests PRIVATE glm::glm Catch2::Catch2WithMain) -compiler_flags(fastgltf_tests) +fastgltf_compiler_flags(fastgltf_tests) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/catch2") add_subdirectory(deps/catch2) @@ -60,4 +60,4 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gltf_loaders/assimp") target_compile_definitions(fastgltf_tests PRIVATE HAS_ASSIMP=1) endif() -add_source_directory(TARGET fastgltf_tests FOLDER ".") +fastgltf_add_source_directory(TARGET fastgltf_tests FOLDER ".")