The open source OpenXR runtime

cmake: Build all math-heavy code with optimization.

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
4ffb271c 75442c43

+29 -5
+9 -1
CompilerFlags.cmake
··· 1 1 # Copyright 2018-2023, Collabora, Ltd. 2 2 # SPDX-License-Identifier: BSL-1.0 3 3 4 - if(NOT MSVC) 4 + 5 + # Target used for applying more aggressive optimizations to math-heavy code 6 + add_library(xrt-optimized-math INTERFACE) 7 + 8 + if(MSVC) 9 + target_compile_options(xrt-optimized-math INTERFACE $<IF:$<CONFIG:Debug>,/O2,/O3>) 10 + else() 5 11 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wno-unused-parameter") 6 12 set(CMAKE_C_FLAGS 7 13 "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Werror=incompatible-pointer-types" ··· 15 21 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mfpmath=sse") 16 22 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mfpmath=sse") 17 23 endif() 24 + 25 + target_compile_options(xrt-optimized-math INTERFACE $<IF:$<CONFIG:Debug>,-O2,-O3>) 18 26 endif() 19 27 20 28 if(NOT WIN32)
+5 -1
src/xrt/auxiliary/math/CMakeLists.txt
··· 37 37 m_vec2.h 38 38 m_vec3.h 39 39 ) 40 - target_link_libraries(aux_math PUBLIC aux-includes aux_util) 40 + target_link_libraries( 41 + aux_math 42 + PUBLIC aux-includes aux_util 43 + PRIVATE xrt-optimized-math 44 + ) 41 45 target_include_directories(aux_math SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})
+6 -1
src/xrt/auxiliary/tracking/CMakeLists.txt
··· 14 14 target_link_libraries( 15 15 aux_tracking 16 16 PUBLIC aux-includes xrt-external-cjson 17 - PRIVATE aux_math aux_util xrt-external-flexkalman xrt-external-hungarian 17 + PRIVATE 18 + aux_math 19 + aux_util 20 + xrt-external-flexkalman 21 + xrt-external-hungarian 22 + xrt-optimized-math 18 23 ) 19 24 target_include_directories(aux_tracking SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) 20 25
+7 -1
src/xrt/tracking/hand/mercury/CMakeLists.txt
··· 1 - # Copyright 2019-2022, Collabora, Ltd. 1 + # Copyright 2019-2023, Collabora, Ltd. 2 2 # SPDX-License-Identifier: BSL-1.0 3 3 4 4 # Mercury hand tracking library! 5 5 6 6 add_subdirectory(kine_lm) 7 7 8 + # t_ht_mercury_model 8 9 add_library(t_ht_mercury_model STATIC hg_model.cpp) 9 10 10 11 target_link_libraries(t_ht_mercury_model PRIVATE aux_math aux_tracking aux_os aux_util) ··· 20 21 aux_tracking 21 22 aux_os 22 23 aux_util 24 + xrt-optimized-math 23 25 ${OpenCV_LIBRARIES} 24 26 ONNXRuntime::ONNXRuntime 25 27 ) 26 28 29 + # t_ht_mercury_distorter 27 30 add_library(t_ht_mercury_distorter STATIC hg_image_distorter.cpp) 28 31 29 32 target_link_libraries(t_ht_mercury_distorter PRIVATE aux_math aux_tracking aux_os aux_util) ··· 39 42 aux_tracking 40 43 aux_os 41 44 aux_util 45 + xrt-optimized-math 42 46 ${OpenCV_LIBRARIES} 43 47 ONNXRuntime::ONNXRuntime # no, wrong 44 48 ) 45 49 50 + # t_ht_mercury 46 51 add_library(t_ht_mercury STATIC hg_sync.cpp hg_sync.hpp hg_interface.h kine_common.hpp) 47 52 48 53 target_link_libraries( ··· 57 62 t_ht_mercury_kine_lm 58 63 t_ht_mercury_model 59 64 t_ht_mercury_distorter 65 + xrt-optimized-math 60 66 ${OpenCV_LIBRARIES} 61 67 ) 62 68
+2 -1
src/xrt/tracking/hand/mercury/kine_lm/CMakeLists.txt
··· 1 - # Copyright 2022, Collabora, Ltd. 1 + # Copyright 2022-2023, Collabora, Ltd. 2 2 # SPDX-License-Identifier: BSL-1.0 3 3 4 4 add_library( ··· 14 14 aux_os 15 15 aux_util 16 16 xrt-external-tinyceres 17 + xrt-optimized-math 17 18 ) 18 19 19 20 target_include_directories(t_ht_mercury_kine_lm SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})