mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
cmake - fix missing xml.lib in debug builds #7413
After 5d56025 we were using `LibXml2::LibXml2` instead of `LIBXML2_LIBRARIES` for linking, but this target was missing debug variants leading to issues during linking.
This commit is contained in:
+14
-16
@@ -5,9 +5,8 @@
|
|||||||
# If input variables are not specified, try to find LibXml2 config.
|
# If input variables are not specified, try to find LibXml2 config.
|
||||||
# Input variables could also be provided as environment variables.
|
# Input variables could also be provided as environment variables.
|
||||||
#
|
#
|
||||||
# Output variables:
|
# Output targets:
|
||||||
# - `LIBXML2_INCLUDE_DIR`
|
# - `LibXml2::LibXml2`
|
||||||
# - `LIBXML2_LIBRARIES`
|
|
||||||
#
|
#
|
||||||
|
|
||||||
# To avoid cyclic calls to this file
|
# To avoid cyclic calls to this file
|
||||||
@@ -27,23 +26,22 @@ if((NOT LIBXML2_INCLUDE_DIR AND NOT LIBXML2_LIBRARIES))
|
|||||||
else()
|
else()
|
||||||
message(STATUS "Found LibXml2 config: ${LibXml2_DIR}")
|
message(STATUS "Found LibXml2 config: ${LibXml2_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET LibXml2::LibXml2)
|
|
||||||
# Config mode already gives us the target
|
|
||||||
set(LIBXML2_LIBRARIES LibXml2::LibXml2)
|
|
||||||
get_target_property(LIBXML2_INCLUDE_DIR LibXml2::LibXml2 INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
else()
|
|
||||||
# Module mode (Ubuntu)
|
|
||||||
set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES})
|
|
||||||
set(LIBXML2_INCLUDE_DIR ${LibXml2_INCLUDE_DIRS})
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
find_package(LibXml2 REQUIRED)
|
find_package(LibXml2 REQUIRED)
|
||||||
|
if(MSVC)
|
||||||
|
# Unset `IMPORTED_LOCATION` and set it manually.
|
||||||
|
set_property(TARGET LibXml2::LibXml2 PROPERTY IMPORTED_LOCATION)
|
||||||
|
get_release_variant(LIBXML2_RELEASE_LIB "${LIBXML2_LIBRARIES}" "d")
|
||||||
|
get_debug_variant(LIBXML2_DEBUG_LIB "${LIBXML2_LIBRARIES}" "d")
|
||||||
|
set_target_properties(LibXml2::LibXml2
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_CONFIGURATIONS "Release;Debug"
|
||||||
|
IMPORTED_LOCATION_RELEASE "${LIBXML2_RELEASE_LIB}"
|
||||||
|
IMPORTED_LOCATION_DEBUG "${LIBXML2_DEBUG_LIB}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC AND NOT LibXml2_DIR)
|
|
||||||
add_debug_variants(LIBXML2_LIBRARIES "${LIBXML2_LIBRARIES}" d)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Restore module path.
|
# Restore module path.
|
||||||
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
|
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
|
||||||
|
|||||||
@@ -113,6 +113,30 @@ function(add_debug_variants NAME LIBRARIES POSTFIX)
|
|||||||
set(${NAME} ${LIBRARIES} PARENT_SCOPE)
|
set(${NAME} ${LIBRARIES} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# E.g.
|
||||||
|
# - `get_release_variant(MYLIB "mylibd.lib" "d")` -> `MYLIB = "mylib.lib"`
|
||||||
|
# - `get_release_variant(MYLIB "mylib.lib" "d")` -> `MYLIB = "mylib.lib"`
|
||||||
|
function(get_release_variant NAME LIBRARY POSTFIX)
|
||||||
|
set(RELEASE_SUFFIX ".lib")
|
||||||
|
set(DEBUG_SUFFIX "${POSTFIX}${RELEASE_SUFFIX}")
|
||||||
|
if("${LIBRARY}" MATCHES "${DEBUG_SUFFIX}$")
|
||||||
|
string(REPLACE "${DEBUG_SUFFIX}" "${RELEASE_SUFFIX}" LIBRARY ${LIBRARY})
|
||||||
|
endif()
|
||||||
|
set(${NAME} "${LIBRARY}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# E.g.
|
||||||
|
# - `get_debug_variant(MYLIB "mylib.lib" "d")` -> `MYLIB = "mylibd.lib"`
|
||||||
|
# - `get_debug_variant(MYLIB "mylibd.lib" "d")` -> `MYLIB = "mylibd.lib"`
|
||||||
|
function(get_debug_variant NAME LIBRARY POSTFIX)
|
||||||
|
set(RELEASE_SUFFIX ".lib")
|
||||||
|
set(DEBUG_SUFFIX "${POSTFIX}${RELEASE_SUFFIX}")
|
||||||
|
if(NOT "${LIBRARY}" MATCHES "${DEBUG_SUFFIX}$" AND "${LIBRARY}" MATCHES "${RELEASE_SUFFIX}$")
|
||||||
|
string(REPLACE "${RELEASE_SUFFIX}" "${DEBUG_SUFFIX}" LIBRARY ${LIBRARY})
|
||||||
|
endif()
|
||||||
|
set(${NAME} "${LIBRARY}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
function(files_for_ifc_version IFC_VERSION RESULT_NAME)
|
function(files_for_ifc_version IFC_VERSION RESULT_NAME)
|
||||||
set(IFC_PARSE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src/ifcparse)
|
set(IFC_PARSE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src/ifcparse)
|
||||||
set(${RESULT_NAME}
|
set(${RESULT_NAME}
|
||||||
|
|||||||
@@ -39,10 +39,6 @@ if(IFCXML_SUPPORT)
|
|||||||
target_compile_definitions(IfcParse PUBLIC WITH_IFCXML)
|
target_compile_definitions(IfcParse PUBLIC WITH_IFCXML)
|
||||||
set(SWIG_DEFINES ${SWIG_DEFINES} -DWITH_IFCXML PARENT_SCOPE)
|
set(SWIG_DEFINES ${SWIG_DEFINES} -DWITH_IFCXML PARENT_SCOPE)
|
||||||
|
|
||||||
if(LibXml2_DIR)
|
|
||||||
target_compile_definitions(IfcParse PRIVATE ${LIBXML2_DEFINITIONS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(IfcParse LibXml2::LibXml2)
|
target_link_libraries(IfcParse LibXml2::LibXml2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
include_directories(${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR}
|
include_directories(${Boost_INCLUDE_DIRS}
|
||||||
${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/svgpp/include
|
${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/svgpp/include
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -122,11 +122,7 @@ file(GLOB LIB_H_FILES src/*.h)
|
|||||||
file(GLOB LIB_CPP_FILES src/svgfill.cpp src/arrange_polygons.cpp)
|
file(GLOB LIB_CPP_FILES src/svgfill.cpp src/arrange_polygons.cpp)
|
||||||
set(LIB_SRC_FILES ${LIB_H_FILES} ${LIB_CPP_FILES})
|
set(LIB_SRC_FILES ${LIB_H_FILES} ${LIB_CPP_FILES})
|
||||||
add_library(svgfill ${LIB_SRC_FILES})
|
add_library(svgfill ${LIB_SRC_FILES})
|
||||||
if(LibXml2_DIR)
|
target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} LibXml2::LibXml2 ${CGAL_LIBRARIES})
|
||||||
find_package(LibXml2 CONFIG REQUIRED)
|
|
||||||
target_compile_definitions(svgfill PRIVATE ${LIBXML2_DEFINITIONS})
|
|
||||||
endif()
|
|
||||||
target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES} ${CGAL_LIBRARIES})
|
|
||||||
|
|
||||||
add_executable(svgfill_exe src/main.cpp)
|
add_executable(svgfill_exe src/main.cpp)
|
||||||
target_link_libraries(svgfill_exe svgfill)
|
target_link_libraries(svgfill_exe svgfill)
|
||||||
|
|||||||
Reference in New Issue
Block a user