Skip to content

Commit ddb347a

Browse files
authored
Merge pull request #24 from commontk/fix-libxml-build-to-support-dsr2xml
Fix libxml build to support dsr2xml
2 parents 46352f5 + aca8139 commit ddb347a

File tree

9 files changed

+1002
-1052
lines changed

9 files changed

+1002
-1052
lines changed

CMake/Externals/External_DCMTK.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ endif()
1919
if(NOT DEFINED DCMTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
2020

2121
set(${proj}_REPOSITORY ${git_protocol}://github.com/jcfr/DCMTK)
22-
set(${proj}_GIT_TAG "693eabe2f2a8285be4027b45d816774d50389256") # Based of DCMTK-3.6.1_20161102
22+
set(${proj}_GIT_TAG "c985845994fa378916c25954ee3e65914ee580ca") # Based of DCMTK-3.6.1_20161102
2323

2424
set(app_cache_args)
2525

CMake/Externals/External_LibXml2.cmake

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,56 @@ set(${proj}_DEPENDENCIES "")
88
ExternalProject_Include_Dependencies(${proj} PROJECT_VAR proj DEPENDS_VAR ${proj}_DEPENDENCIES)
99

1010
if(${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
11-
11+
message(FATAL_ERROR "Enabling ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj} is not supported !")
1212
endif()
1313

1414
# Sanity checks
15-
if(DEFINED ${proj}_DIR AND NOT EXISTS ${${proj}_DIR})
16-
message(FATAL_ERROR "<proj>_DIR variable is defined but corresponds to non-existing directory")
15+
if(DEFINED LIBXML2_INCLUDE_DIR AND NOT EXISTS ${LIBXML2_INCLUDE_DIR})
16+
message(FATAL_ERROR "LIBXML2_INCLUDE_DIR variable is defined but corresponds to non-existing directory")
17+
endif()
18+
if(DEFINED LIBXML2_LIBRARIES AND NOT EXISTS ${LIBXML2_LIBRARIES})
19+
message(FATAL_ERROR "LIBXML2_LIBRARIES variable is defined but corresponds to non-existing file")
1720
endif()
1821

19-
if(NOT DEFINED ${proj}_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
22+
if((NOT DEFINED LIBXML2_INCLUDE_DIR OR NOT DEFINED LIBXML2_LIBRARIES) AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
2023

2124
set(EP_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj})
2225
set(EP_BINARY_DIR ${CMAKE_BINARY_DIR}/${proj}-build)
23-
set(EP_INSTALL_DIR ${CMAKE_BINARY_DIR}/${proj}-install)
24-
25-
include(ExternalProjectForNonCMakeProject)
26-
27-
# Adapted from http://mozakai.blogspot.com/2012/03/howto-port-cc-library-to-javascript.html
28-
29-
# environment
30-
set(_env_script ${CMAKE_BINARY_DIR}/${proj}_Env.cmake)
31-
ExternalProject_Write_SetBuildEnv_Commands(${_env_script})
32-
file(APPEND ${_env_script}
33-
"#------------------------------------------------------------------------------
34-
# Added by '${CMAKE_CURRENT_LIST_FILE}'
35-
include(\"${${CMAKE_PROJECT_NAME}_CMAKE_DIR}/ExternalProjectForNonCMakeProject.cmake\")
36-
set(CMAKE_BINARY_DIR \"${CMAKE_BINARY_DIR}\")
37-
38-
")
3926

40-
set(_src_dir ${EP_SOURCE_DIR})
41-
42-
# configure step
43-
set(_configure_script ${CMAKE_BINARY_DIR}/${proj}_configure_step.cmake)
44-
file(WRITE ${_configure_script}
45-
"include(\"${_env_script}\")
46-
set(${proj}_WORKING_DIR \"${_src_dir}\")
47-
ExternalProject_Execute(${proj} \"configure\" ${EMSCRIPTEN_ROOT_PATH}/emconfigure ./configure
48-
--without-python --without-iconv --without-http --without-ftp
49-
)
50-
")
51-
52-
# build step
53-
set(_build_script ${CMAKE_BINARY_DIR}/${proj}_build_step.cmake)
54-
file(WRITE ${_build_script}
55-
"include(\"${_env_script}\")
56-
set(${proj}_WORKING_DIR \"${_src_dir}\")
57-
ExternalProject_Execute(${proj} \"build\" ${EMSCRIPTEN_ROOT_PATH}/emmake make)
58-
")
59-
6027
ExternalProject_Add(${proj}
6128
${${proj}_EP_ARGS}
6229
URL "ftp://xmlsoft.org/libxml2/libxml2-2.9.8.tar.gz"
6330
URL_MD5 "b786e353e2aa1b872d70d5d1ca0c740d"
6431
DOWNLOAD_DIR ${DOWNLOAD_CACHE_DIR}
6532
DOWNLOAD_NO_PROGRESS 1
6633
SOURCE_DIR ${EP_SOURCE_DIR}
67-
BUILD_IN_SOURCE 1
68-
CONFIGURE_COMMAND ${CMAKE_COMMAND} -P ${_configure_script}
69-
BUILD_COMMAND ${CMAKE_COMMAND} -P ${_build_script}
34+
BINARY_DIR ${EP_BINARY_DIR}
35+
PATCH_COMMAND
36+
${CMAKE_COMMAND} -E copy
37+
${CMAKE_SOURCE_DIR}/CMake/Externals/LibXml2-CMakeLists.txt
38+
${EP_SOURCE_DIR}/CMakeLists.txt
39+
COMMAND ${CMAKE_COMMAND} -E copy
40+
${CMAKE_SOURCE_DIR}/CMake/Externals/LibXml2-config.h
41+
${EP_SOURCE_DIR}/include/config.h
42+
COMMAND ${CMAKE_COMMAND} -E copy
43+
${CMAKE_SOURCE_DIR}/CMake/Externals/LibXml2-xmlversion.h
44+
${EP_SOURCE_DIR}/include/libxml/xmlversion.h
45+
CMAKE_CACHE_ARGS
46+
${EMSCRIPTEN_TOOLCHAIN_OPTIONS}
47+
# LibXml2 options
48+
INSTALL_COMMAND ""
7049
USES_TERMINAL_DOWNLOAD 1
7150
USES_TERMINAL_UPDATE 1
7251
USES_TERMINAL_CONFIGURE 1
7352
USES_TERMINAL_BUILD 1
74-
INSTALL_COMMAND ""
53+
USES_TERMINAL_INSTALL 1
7554
DEPENDS
7655
${${proj}_DEPENDENCIES}
7756
)
78-
set(${proj}_DIR ${_src_dir})
79-
set(LIBXML2_INCLUDE_DIR ${${proj}_DIR}/include)
80-
set(LIBXML2_LIBRARIES ${${proj}_DIR}/.libs/libxml2.a)
57+
set(LIBXML2_INCLUDE_DIR ${EP_SOURCE_DIR}/include)
58+
set(LIBXML2_LIBRARIES ${EP_BINARY_DIR}/libxml2.so)
8159
else()
82-
# The project is provided using <proj>_DIR, nevertheless since other project may depend on <proj>,
60+
# The project is provided using LIBXML2_LIBRARIES and LIBXML2_LIBRARIES, nevertheless since other project may depend on <proj>,
8361
# let's add an 'empty' one
8462
ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES})
8563
endif()
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
3+
project( xml2 )
4+
5+
set(srcs
6+
buf.c
7+
c14n.c
8+
catalog.c
9+
chvalid.c
10+
debugXML.c
11+
dict.c
12+
DOCBparser.c
13+
encoding.c
14+
entities.c
15+
error.c
16+
globals.c
17+
hash.c
18+
# HTMLparser.c # WITH_HTML
19+
# HTMLtree.c # WITH_HTML
20+
legacy.c
21+
list.c
22+
# nanoftp.c # WITH_FTP
23+
# nanohttp.c # WITH_HTTP
24+
parser.c
25+
parserInternals.c
26+
pattern.c
27+
relaxng.c
28+
#runsuite.c
29+
#runtest.c
30+
#runxmlconf.c # executable
31+
SAX2.c
32+
SAX.c
33+
schematron.c
34+
#testapi.c
35+
#testAutomata.c
36+
#testC14N.c
37+
#testchar.c
38+
#testdict.c
39+
#testdso.c
40+
#testHTML.c
41+
#testlimits.c
42+
#testModule.c
43+
#testReader.c
44+
#testrecurse.c
45+
#testRegexp.c
46+
#testRelax.c
47+
#testSAX.c
48+
#testSchemas.c
49+
#testThreads.c
50+
#testThreadsWin32.c
51+
#testURI.c
52+
#testXPath.c
53+
threads.c
54+
tree.c
55+
trio.c
56+
trionan.c
57+
triostr.c
58+
uri.c
59+
valid.c
60+
xinclude.c
61+
xlink.c
62+
#xmlcatalog.c # executable
63+
xmlIO.c
64+
#xmllint.c # executable
65+
xmlmemory.c
66+
xmlmodule.c
67+
xmlreader.c
68+
xmlregexp.c
69+
xmlsave.c
70+
xmlschemas.c
71+
xmlschemastypes.c
72+
xmlstring.c
73+
xmlunicode.c
74+
xmlwriter.c
75+
xpath.c
76+
xpointer.c
77+
xzlib.c
78+
)
79+
80+
#--without-python --without-iconv --without-http --without-ftp --enable-shared --disable-static
81+
82+
add_library( xml2 SHARED ${srcs})
83+
target_include_directories(xml2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
84+
target_compile_definitions(xml2 PUBLIC HAVE_CONFIG_H HAVE_ERRNO_H LIBXML_THREAD_ENABLED)

0 commit comments

Comments
 (0)