Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Expat as a subdirectory instead of external. #7

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 8 additions & 64 deletions Config.cmake/fmixml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,70 +139,14 @@ set(FMIXMLSOURCE

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXML_STATIC -DFMI_XML_QUERY")

include(ExternalProject)

set(EXPAT_SETTINGS
-DBUILD_tools:BOOLEAN=OFF
-DBUILD_examples:BOOLEAN=OFF
-DBUILD_tests:BOOLEAN=OFF
-DBUILD_shared:BOOLEAN=OFF
-DXML_DTD:BOOLEAN=OFF
-DXML_NS:BOOLEAN=OFF
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_LINK_LIBRARY_FLAG:STRING=${CMAKE_LINK_LIBRARY_FLAG}
-DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/ExpatEx/install
)

ExternalProject_Add(
expatex
PREFIX "${FMIXML_EXPAT_DIR}"
SOURCE_DIR "${FMIXML_EXPAT_DIR}"
CMAKE_CACHE_ARGS ${EXPAT_SETTINGS}
BINARY_DIR ${CMAKE_BINARY_DIR}/ExpatEx
INSTALL_DIR ${CMAKE_BINARY_DIR}/ExpatEx/install
TMP_DIR ${CMAKE_BINARY_DIR}/ExpatEx/tmp
STAMP_DIR ${CMAKE_BINARY_DIR}/ExpatEx/stamp
)

ExternalProject_Add_Step(
expatex dependent_reconfigure
DEPENDEES configure
DEPENDERS build
COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${EXPAT_SETTINGS} ${FMIXML_EXPAT_DIR}"
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${EXPAT_SETTINGS} "${FMIXML_EXPAT_DIR}"
DEPENDS ${CMAKE_BINARY_DIR}/CMakeCache.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ExpatEx
)

add_dependencies(expatex ${CMAKE_BINARY_DIR}/CMakeCache.txt ${FMILIBRARYHOME}/CMakeLists.txt)

set(expatlib "${CMAKE_BINARY_DIR}/ExpatEx/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}")

add_library(expat STATIC IMPORTED)

set_target_properties(
expat PROPERTIES
IMPORTED_LOCATION "${expatlib}"
)

add_dependencies(expat expatex)

if(FMILIB_INSTALL_SUBLIBS)
install(FILES
"${CMAKE_BINARY_DIR}/ExpatEx/install/lib/${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}"
DESTINATION lib)
endif()

set(EXPAT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ExpatEx/install/include)

### Add the options of expat to the cache and add it as subdirectory.
set(BUILD_tools OFF CACHE BOOL "build the xmlwf tool for expat library")
set(BUILD_examples OFF CACHE BOOL "build the examples for expat library")
set(BUILD_tests OFF CACHE BOOL "build the tests for expat library")
set(BUILD_shared OFF CACHE BOOL "build a shared expat library")
add_subdirectory(ThirdParty/Expat/expat-2.1.0)

set(EXPAT_INCLUDE_DIRS ThirdParty/Expat/expat-2.1.0/lib)
include_directories("${EXPAT_INCLUDE_DIRS}" "${FMILIB_THIRDPARTYLIBS}/FMI/" "${FMIXMLGENDIR}/FMI1" "${FMIXMLGENDIR}/FMI2")

PREFIXLIST(FMIXMLSOURCE ${FMIXMLDIR}/)
Expand Down
2 changes: 1 addition & 1 deletion ThirdParty/Expat/expat-2.1.0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ endif(BUILD_tests)

include(ConfigureChecks.cmake)

include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/lib)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/lib)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996)
endif(MSVC)
Expand Down