Skip to content

Commit

Permalink
- update expat find modules
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed Apr 14, 2022
1 parent 0b327bc commit 4f9efd0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 64 deletions.
21 changes: 5 additions & 16 deletions src/libCombine/CMakeModules/FindEXPAT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,22 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str
REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$")

unset(EXPAT_VERSION)
unset(EXPAT_VERSION CACHE)
set(_STARTED FALSE)
foreach(VPART MAJOR MINOR MICRO)
foreach(VLINE ${expat_version_str})
if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
if(EXPAT_VERSION)
if(_STARTED)
string(APPEND EXPAT_VERSION ".${EXPAT_VERSION_PART}")
else()
set(EXPAT_VERSION "${EXPAT_VERSION_PART}")
set(_STARTED TRUE)
endif()
endif()
endforeach()
endforeach()
unset(_STARTED)
endif ()


Expand Down Expand Up @@ -128,16 +131,12 @@ set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST)


message(STATUS "EXPAT_EXPAT_TEST = ${EXPAT_EXPAT_TEST}")

if (NOT EXPAT_EXPAT_TEST)
set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
set(CMAKE_REQUIRED_DEFINITIONS "-DXML_STATIC=1")

CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST2)
message(STATUS "EXPAT_EXPAT_TEST2 = ${EXPAT_EXPAT_TEST2}")
if (EXPAT_EXPAT_TEST2)
set_target_properties(EXPAT::EXPAT PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "XML_STATIC=1"
Expand All @@ -153,16 +152,6 @@ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_CACHE})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_CACHE})
endif()

# TODO: compilation against expat fails with static runtime currently
#if (MSVC AND WITH_STATIC_RUNTIME)
# get_target_property(EXPAT_DEFS EXPAT::EXPAT INTERFACE_COMPILE_DEFINITIONS)
# set_target_properties(EXPAT::EXPAT PROPERTIES
# INTERFACE_COMPILE_DEFINITIONS "_CRT_RAND_S;${EXPAT_DEFS}"
# )
#endif()



include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
Expand Down
21 changes: 5 additions & 16 deletions src/libSBML/CMakeModules/FindEXPAT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,22 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str
REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$")

unset(EXPAT_VERSION)
unset(EXPAT_VERSION CACHE)
set(_STARTED FALSE)
foreach(VPART MAJOR MINOR MICRO)
foreach(VLINE ${expat_version_str})
if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
if(EXPAT_VERSION)
if(_STARTED)
string(APPEND EXPAT_VERSION ".${EXPAT_VERSION_PART}")
else()
set(EXPAT_VERSION "${EXPAT_VERSION_PART}")
set(_STARTED TRUE)
endif()
endif()
endforeach()
endforeach()
unset(_STARTED)
endif ()


Expand Down Expand Up @@ -128,16 +131,12 @@ set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST)


message(STATUS "EXPAT_EXPAT_TEST = ${EXPAT_EXPAT_TEST}")

if (NOT EXPAT_EXPAT_TEST)
set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
set(CMAKE_REQUIRED_DEFINITIONS "-DXML_STATIC=1")

CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST2)
message(STATUS "EXPAT_EXPAT_TEST2 = ${EXPAT_EXPAT_TEST2}")
if (EXPAT_EXPAT_TEST2)
set_target_properties(EXPAT::EXPAT PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "XML_STATIC=1"
Expand All @@ -153,16 +152,6 @@ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_CACHE})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_CACHE})
endif()

# TODO: compilation against expat fails with static runtime currently
#if (MSVC AND WITH_STATIC_RUNTIME)
# get_target_property(EXPAT_DEFS EXPAT::EXPAT INTERFACE_COMPILE_DEFINITIONS)
# set_target_properties(EXPAT::EXPAT PROPERTIES
# INTERFACE_COMPILE_DEFINITIONS "_CRT_RAND_S;${EXPAT_DEFS}"
# )
#endif()



include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
Expand Down
21 changes: 5 additions & 16 deletions src/libSEDML/CMakeModules/FindEXPAT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,22 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str
REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$")

unset(EXPAT_VERSION)
unset(EXPAT_VERSION CACHE)
set(_STARTED FALSE)
foreach(VPART MAJOR MINOR MICRO)
foreach(VLINE ${expat_version_str})
if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
if(EXPAT_VERSION)
if(_STARTED)
string(APPEND EXPAT_VERSION ".${EXPAT_VERSION_PART}")
else()
set(EXPAT_VERSION "${EXPAT_VERSION_PART}")
set(_STARTED TRUE)
endif()
endif()
endforeach()
endforeach()
unset(_STARTED)
endif ()


Expand Down Expand Up @@ -128,16 +131,12 @@ set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST)


message(STATUS "EXPAT_EXPAT_TEST = ${EXPAT_EXPAT_TEST}")

if (NOT EXPAT_EXPAT_TEST)
set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
set(CMAKE_REQUIRED_DEFINITIONS "-DXML_STATIC=1")

CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST2)
message(STATUS "EXPAT_EXPAT_TEST2 = ${EXPAT_EXPAT_TEST2}")
if (EXPAT_EXPAT_TEST2)
set_target_properties(EXPAT::EXPAT PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "XML_STATIC=1"
Expand All @@ -153,16 +152,6 @@ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_CACHE})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_CACHE})
endif()

# TODO: compilation against expat fails with static runtime currently
#if (MSVC AND WITH_STATIC_RUNTIME)
# get_target_property(EXPAT_DEFS EXPAT::EXPAT INTERFACE_COMPILE_DEFINITIONS)
# set_target_properties(EXPAT::EXPAT PROPERTIES
# INTERFACE_COMPILE_DEFINITIONS "_CRT_RAND_S;${EXPAT_DEFS}"
# )
#endif()



include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
Expand Down
21 changes: 5 additions & 16 deletions src/libnuml/CMakeModules/FindEXPAT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,22 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str
REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$")

unset(EXPAT_VERSION)
unset(EXPAT_VERSION CACHE)
set(_STARTED FALSE)
foreach(VPART MAJOR MINOR MICRO)
foreach(VLINE ${expat_version_str})
if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
if(EXPAT_VERSION)
if(_STARTED)
string(APPEND EXPAT_VERSION ".${EXPAT_VERSION_PART}")
else()
set(EXPAT_VERSION "${EXPAT_VERSION_PART}")
set(_STARTED TRUE)
endif()
endif()
endforeach()
endforeach()
unset(_STARTED)
endif ()


Expand Down Expand Up @@ -128,16 +131,12 @@ set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST)


message(STATUS "EXPAT_EXPAT_TEST = ${EXPAT_EXPAT_TEST}")

if (NOT EXPAT_EXPAT_TEST)
set(CMAKE_REQUIRED_LIBRARIES "${EXPAT_LIBRARY}")
set(CMAKE_REQUIRED_INCLUDES "${EXPAT_INCLUDE_DIR}")
set(CMAKE_REQUIRED_DEFINITIONS "-DXML_STATIC=1")

CHECK_C_SOURCE_COMPILES("${EXPAT_EXPAT_CODE}" EXPAT_EXPAT_TEST2)
message(STATUS "EXPAT_EXPAT_TEST2 = ${EXPAT_EXPAT_TEST2}")
if (EXPAT_EXPAT_TEST2)
set_target_properties(EXPAT::EXPAT PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "XML_STATIC=1"
Expand All @@ -153,16 +152,6 @@ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_CACHE})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_CACHE})
endif()

# TODO: compilation against expat fails with static runtime currently
#if (MSVC AND WITH_STATIC_RUNTIME)
# get_target_property(EXPAT_DEFS EXPAT::EXPAT INTERFACE_COMPILE_DEFINITIONS)
# set_target_properties(EXPAT::EXPAT PROPERTIES
# INTERFACE_COMPILE_DEFINITIONS "_CRT_RAND_S;${EXPAT_DEFS}"
# )
#endif()



include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
Expand Down

0 comments on commit 4f9efd0

Please sign in to comment.