Skip to content

Commit

Permalink
Fix: Prefix CMake macros to avoid naming collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Nov 22, 2023
1 parent 3c0b5d1 commit d088f80
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/deps/simdjson> $<INSTALL_INTERFACE:include>)
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
Expand Down Expand Up @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<INSTALL_INTERFACE:include>)

Expand Down
2 changes: 1 addition & 1 deletion cmake/add_source_directory.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmake/compiler_flags.cmake
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 $<$<CONFIG:DEBUG>:/Ob2>)
Expand Down
2 changes: 1 addition & 1 deletion examples/gl_viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ".")
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ".")

0 comments on commit d088f80

Please sign in to comment.