Skip to content

Commit

Permalink
Merge pull request #250 from sbmlteam/cmake-libxml-fix
Browse files Browse the repository at this point in the history
Cmake libxml fix
  • Loading branch information
fbergmann authored Jul 15, 2022
2 parents 40c0e0c + 6acbbf5 commit 6a512ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ set(LIBSBML_XML_LIBRARY_LIBS)

if(WITH_EXPAT)

if(NOT TARGET EXPAT::EXPAT)
find_package(EXPAT REQUIRED)
endif()

add_definitions( -DUSE_EXPAT )
list(APPEND SWIG_EXTRA_ARGS -DUSE_EXPAT)
Expand Down
19 changes: 14 additions & 5 deletions CMakeModules/FindLIBXML.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(CheckLibraryExists)

string(TOUPPER ${PROJECT_NAME} _UPPER_PROJECT_NAME)
set(_PROJECT_DEPENDENCY_DIR ${_UPPER_PROJECT_NAME}_DEPENDENCY_DIR)

Expand All @@ -23,7 +25,7 @@ find_path(LIBXML_INCLUDE_DIR
PATHS ${${_PROJECT_DEPENDENCY_DIR}}/include
${${_PROJECT_DEPENDENCY_DIR}}/include/libxml2
NO_DEFAULT_PATH
)
)


if (NOT LIBXML_INCLUDE_DIR)
Expand Down Expand Up @@ -71,6 +73,13 @@ if (WIN32)
set(ADDITIONAL_LIBS "ws2_32.lib;${ADDITIONAL_LIBS}")
endif()


CHECK_LIBRARY_EXISTS(m sin "" HAVE_LIB_M)

if (HAVE_LIB_M)
set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} m)
endif (HAVE_LIB_M)

if(NOT TARGET LIBXML::LIBXML)
add_library(LIBXML::LIBXML UNKNOWN IMPORTED)
set_target_properties(LIBXML::LIBXML PROPERTIES
Expand All @@ -83,7 +92,7 @@ endif()

# figure out if we need XML_STATIC flag
if (LIBXML_INCLUDE_DIR AND LIBXML_LIBRARY)

set(LIBXML_LIBXML_CODE
"
#include <libxml/xmlversion.h>
Expand Down Expand Up @@ -130,10 +139,10 @@ if (LIBXML_LIBXML_TEST2)
)
else()
message(FATAL_ERROR "Unable to compile a test executable against LIBXML
LIBXML_INCLUDE_DIR = ${LIBXML_INCLUDE_DIR}
LIBXML_LIBRARY = ${LIBXML_LIBRARY}
")
endif()

Expand All @@ -143,7 +152,7 @@ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_CACHE})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_CACHE})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_CACHE})
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
Expand Down

0 comments on commit 6a512ff

Please sign in to comment.