Skip to content

Commit

Permalink
Change: Always enable function inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Dec 24, 2022
1 parent ae801fc commit b0bbdfe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ if (FASTGLTF_DOWNLOAD_SIMDJSON)
target_compile_features(fastgltf_simdjson PUBLIC cxx_std_17)
target_include_directories(fastgltf_simdjson PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/simdjson> $<INSTALL_INTERFACE:include>)
compiler_flags(TARGET fastgltf_simdjson)
enable_debug_inlining(TARGET fastgltf_simdjson)

install(
FILES simdjson/simdjson.h
Expand Down
16 changes: 15 additions & 1 deletion cmake/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@ macro(compiler_flags)
# cpuid, meaning no architecture flags or other compile flags need to be passed.
# See https://github.com/simdjson/simdjson/blob/master/doc/implementation-selection.md.
if (MSVC)
target_compile_options(${PARAM_TARGET} PRIVATE /EHsc $<$<CONFIG:RELEASE>:/O2 /Ob2 /Ot>)
target_compile_options(${PARAM_TARGET} PRIVATE /EHsc $<$<CONFIG:RELEASE>:/O2 /Ob3 /Ot>)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PARAM_TARGET} PRIVATE $<$<CONFIG:RELEASE>:-O3>)
endif()
endmacro()

macro(enable_debug_inlining)
cmake_parse_arguments(PARAM "" "TARGET" "" ${ARGN})

if (PARAM_TARGET STREQUAL "" OR NOT TARGET ${PARAM_TARGET})
return()
endif()

if (MSVC)
target_compile_options(${PARAM_TARGET} PRIVATE $<$<CONFIG:DEBUG>:/Ob2>)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PARAM_TARGET} PRIVATE $<$<CONFIG:DEBUG>:-finline-functions>)
endif()
endmacro()
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_library(fastgltf::fastgltf ALIAS fastgltf)
target_include_directories(fastgltf PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include>)
target_compile_features(fastgltf PUBLIC cxx_std_17)
compiler_flags(TARGET fastgltf)
enable_debug_inlining(TARGET fastgltf_simdjson)

set_target_properties(fastgltf PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES)

Expand Down

0 comments on commit b0bbdfe

Please sign in to comment.