Skip to content

Commit

Permalink
Fix linking debug libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Oct 7, 2024
1 parent b9556fd commit 3aa509a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 23 deletions.
25 changes: 14 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if (NOT Python3_EXECUTABLE)
if(NOT Python3_EXECUTABLE)
# Find Python for Conan and scripts
find_package(
Python3
Expand Down Expand Up @@ -225,8 +225,7 @@ if(MSVC)
/W4 # enable all warnings
/WX # error on warnings
/Zc:__cplusplus # make __cplusplus defined correctly
/bigobj
)
/bigobj)
set(CESIUM_OMNI_CXX_DEFINES
${CESIUM_OMNI_CXX_DEFINES}
_CRT_SECURE_NO_WARNINGS # Avoid erroring on strcpy
Expand Down Expand Up @@ -261,7 +260,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH
-fstrict-enums)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CESIUM_OMNI_CXX_FLAGS ${CESIUM_OMNI_CXX_FLAGS} -Wno-stringop-overflow) # Ignore false positives in libstdc++ in GCC 13.1.1
# Ignore false positives in libstdc++ in GCC 13.1.1
set(CESIUM_OMNI_CXX_FLAGS ${CESIUM_OMNI_CXX_FLAGS} -Wno-stringop-overflow)
endif()

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
Expand Down Expand Up @@ -372,8 +372,7 @@ set(CESIUM_OMNI_CXX_DEFINES
GLM_FORCE_XYZW_ONLY # Disable .rgba and .stpq to make it easier to view values from debugger
GLM_FORCE_EXPLICIT_CTOR # Disallow implicit conversions between dvec3 <-> dvec4, dvec3 <-> fvec3, etc
GLM_FORCE_SIZE_T_LENGTH # Make vec.length() and vec[idx] use size_t instead of int
GLM_ENABLE_EXPERIMENTAL
)
GLM_ENABLE_EXPERIMENTAL)

# Boost is a dependency of USD. It is dynamically linked so we need to set this flag.
set(CESIUM_OMNI_CXX_DEFINES ${CESIUM_OMNI_CXX_DEFINES} BOOST_ALL_DYN_LINK)
Expand Down Expand Up @@ -430,18 +429,22 @@ set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_LIST_DIR}/vcpkg/triplets")

include(${CMAKE_CURRENT_SOURCE_DIR}/extern/cesium-native/cmake/detect-vcpkg-triplet.cmake)

if (NOT VCPKG_TRIPLET)
if (DEFINED ENV{VCPKG_TRIPLET})
if(NOT VCPKG_TRIPLET)
if(DEFINED ENV{VCPKG_TRIPLET})
set(VCPKG_TRIPLET "$ENV{VCPKG_TRIPLET}")
elseif(DETECTED_VCPKG_TRIPLET_ERROR)
message(FATAL_ERROR "${DETECTED_VCPKG_TRIPLET_ERROR}")
else()
set(VCPKG_TRIPLET "${DETECTED_VCPKG_TRIPLET}-omniverse")
if(${USE_NVIDIA_RELEASE_LIBRARIES})
set(VCPKG_TRIPLET "${DETECTED_VCPKG_TRIPLET}-omniverse")
else()
set(VCPKG_TRIPLET "${DETECTED_VCPKG_TRIPLET}-omniverse-kit-debug")
endif()
endif()
endif()

if (NOT EZVCPKG_BASEDIR)
if (DEFINED ENV{EZVCPKG_BASEDIR})
if(NOT EZVCPKG_BASEDIR)
if(DEFINED ENV{EZVCPKG_BASEDIR})
set(EZVCPKG_BASEDIR "$ENV{EZVCPKG_BASEDIR}")
endif()
endif()
Expand Down
28 changes: 22 additions & 6 deletions cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function(add_external_project)
""
""
"PROJECT_NAME;PROJECT_EXTERN_DIRECTORY;EXPECTED_DEBUG_POSTFIX;EXPECTED_RELEASE_POSTFIX;EXPECTED_RELWITHDEBINFO_POSTFIX;EXPECTED_MINSIZEREL_POSTFIX"
"LIBRARIES;OPTIONS"
"LIBRARIES;LIBRARIES_WITH_POSTFIX;OPTIONS"
${ARGN})

include(ExternalProject) # built-in CMake include for ExternalProject_Add
Expand All @@ -297,10 +297,15 @@ $<$<CONFIG:MinSizeRel>:${_EXPECTED_MINSIZEREL_POSTFIX}>")

if(DEFINED _LIBRARIES)
foreach(lib IN LISTS _LIBRARIES)
if(${lib} IN_LIST _LIBRARIES_WITH_POSTFIX)
set(LIBRARY_POSTFIX ${BUILD_TIME_POSTFIX})
else()
set(LIBRARY_POSTFIX "")
endif()
list(
APPEND
LIBRARY_OUTPUT_PATHS
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/$<CONFIG>/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${BUILD_TIME_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/$<CONFIG>/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${LIBRARY_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
endforeach()
endif()
Expand Down Expand Up @@ -371,17 +376,28 @@ $<$<CONFIG:MinSizeRel>:${_EXPECTED_MINSIZEREL_POSTFIX}>")
IMPORTED
GLOBAL)
target_include_directories(${lib} INTERFACE "${PROJECT_INCLUDE_DIR}")
if(${lib} IN_LIST _LIBRARIES_WITH_POSTFIX)
set(LIBRARY_DEBUG_POSTFIX ${_EXPECTED_DEBUG_POSTFIX})
set(LIBRARY_RELEASE_POSTFIX ${_EXPECTED_RELEASE_POSTFIX})
set(LIBRARY_RELWITHDEBINFO_POSTFIX ${_EXPECTED_RELWITHDEBINFO_POSTFIX})
set(LIBRARY_MINSIZEREL_POSTFIX ${_EXPECTED_MINSIZEREL_POSTFIX})
else()
set(LIBRARY_DEBUG_POSTFIX "")
set(LIBRARY_RELEASE_POSTFIX "")
set(LIBRARY_RELWITHDEBINFO_POSTFIX "")
set(LIBRARY_MINSIZEREL_POSTFIX "")
endif()
set_target_properties(
${lib}
PROPERTIES
IMPORTED_LOCATION_DEBUG
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/Debug/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${_EXPECTED_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/Debug/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${LIBRARY_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
IMPORTED_LOCATION_RELEASE
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/Release/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${_EXPECTED_RELEASE_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/Release/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${LIBRARY_RELEASE_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
IMPORTED_LOCATION_RELWITHDEBINFO
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/RelWithDebInfo/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${_EXPECTED_RELWITHDEBINFO_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/RelWithDebInfo/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${LIBRARY_RELWITHDEBINFO_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
IMPORTED_LOCATION_MINSIZEREL
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/MinSizeRel/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${_EXPECTED_MINSIZEREL_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${PROJECT_BINARY_DIR}/${_PROJECT_NAME}/${CMAKE_INSTALL_LIBDIR}/MinSizeRel/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${LIBRARY_MINSIZEREL_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
endforeach()
endif()
Expand Down
11 changes: 7 additions & 4 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ add_external_project(
${SHARPYUV_LIBRARY_NAME}
${ZNG_LIBRARY_NAME}
zstd
LIBRARIES_WITH_POSTFIX
fmt
spdlog
${ZNG_LIBRARY_NAME}
OPTIONS
CESIUM_TESTS_ENABLED=OFF
CESIUM_COVERAGE_ENABLED=OFF
Expand All @@ -159,6 +163,8 @@ add_external_project(
EZVCPKG_BASEDIR=${EZVCPKG_BASEDIR}
PROJECT_EXTERN_DIRECTORY
"${PROJECT_SOURCE_DIR}/extern"
EXPECTED_DEBUG_POSTFIX
"d"
)
# cmake-format: on

Expand Down Expand Up @@ -389,10 +395,7 @@ add_prebuilt_project(
# cmake-format: on

if(WIN32)
set(NVIDIA_ADDITIONAL_LIBRARIES
"${KIT_IMGUI_ROOT}/bin/imgui.dll"
"${KIT_IMGUI_ROOT}/bin/deps/freetype.dll"
)
set(NVIDIA_ADDITIONAL_LIBRARIES "${KIT_IMGUI_ROOT}/bin/imgui.dll" "${KIT_IMGUI_ROOT}/bin/deps/freetype.dll")

set_property(GLOBAL PROPERTY NVIDIA_ADDITIONAL_LIBRARIES_PROPERTY "${NVIDIA_ADDITIONAL_LIBRARIES}")
else()
Expand Down
2 changes: 1 addition & 1 deletion extern/cesium-native
Submodule cesium-native updated 1 files
+2 −2 CMakeLists.txt
8 changes: 8 additions & 0 deletions vcpkg/triplets/x64-windows-omniverse-kit-debug.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake")

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CXX_FLAGS "/MDd /EHsc -D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR")
set(VCPKG_C_FLAGS "${VCPKG_CXX_FLAGS}")
1 change: 0 additions & 1 deletion vcpkg/triplets/x64-windows-omniverse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

# Techically we should be setting /MDd if USE_NVIDIA_RELEASE_LIBRARIES is false
set(VCPKG_CXX_FLAGS "/MD /EHsc -D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR")
set(VCPKG_C_FLAGS "${VCPKG_CXX_FLAGS}")

0 comments on commit 3aa509a

Please sign in to comment.