├── .circleci └── config.yml ├── .dockcross ├── .gitignore ├── CMake ├── ExternalProjectDependency.cmake ├── ExternalProjectForNonCMakeProject.cmake └── Externals │ ├── External_DCMTK.cmake │ ├── External_LibXml2.cmake │ ├── External_PNG.cmake │ ├── External_ZLIB.cmake │ ├── LibXml2-CMakeLists.txt │ ├── LibXml2-config.h │ └── LibXml2-xmlversion.h ├── CMakeLists.txt ├── License.txt ├── README.md ├── javascripts ├── dcmjs-cli ├── post.js └── pre.js └── src ├── CMakeLists.txt └── dcmjs.cpp.in /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: /work 5 | docker: 6 | - image: dockcross/browser-asmjs 7 | steps: 8 | - checkout 9 | - restore_cache: 10 | key: download-cache 11 | - run: 12 | name: Configure and build dcmjs.js 13 | command: | 14 | cmake -Bdcmjs-build -H. -GNinja -DDOWNLOAD_CACHE_DIR:PATH=$HOME/download-cache 15 | ninja -Cdcmjs-build 16 | - save_cache: 17 | key: download-cache-{{ .Revision }} 18 | paths: 19 | - ~/download-cache 20 | - store_artifacts: 21 | path: /work/dcmjs-build/dcmjs-build/bin/ 22 | 23 | 24 | -------------------------------------------------------------------------------- /.dockcross: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | git config --global advice.detachedHead false 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dcmjs 2 | dcmjs-build 3 | dcmjs-download-cache 4 | 5 | # Ignore all dotfiles... 6 | .* 7 | # expect for .circleci 8 | !.circleci 9 | # except for .gitignore 10 | !.gitignore 11 | # except for .dockcross 12 | !.dockcross 13 | 14 | # Exclude QtCreator files ... 15 | CMakeLists.txt.user* 16 | 17 | # Ignore ctags file 18 | tags 19 | 20 | # Ignore Python stuff 21 | *.py[co] 22 | 23 | # Packages 24 | *.egg 25 | *.egg-info 26 | dist 27 | build 28 | eggs 29 | parts 30 | bin 31 | var 32 | sdist 33 | develop-eggs 34 | .installed.cfg 35 | 36 | # Installer logs 37 | pip-log.txt 38 | 39 | # Unit test / coverage reports 40 | .coverage 41 | .tox 42 | 43 | #Translations 44 | *.mo 45 | 46 | #Mr Developer 47 | .mr.developer.cfg 48 | 49 | 50 | # Exclude Kdevelop4 files ... 51 | .kdev* 52 | -------------------------------------------------------------------------------- /CMake/ExternalProjectDependency.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # ExternalProjectDependency 3 | # ------------------------- 4 | # 5 | # .. only:: html 6 | # 7 | # .. contents:: 8 | 9 | ########################################################################### 10 | # 11 | # Library: CTK 12 | # 13 | # Copyright (c) Kitware Inc. 14 | # 15 | # Licensed under the Apache License, Version 2.0 (the "License"); 16 | # you may not use this file except in compliance with the License. 17 | # You may obtain a copy of the License at 18 | # 19 | # http://www.apache.org/licenses/LICENSE-2.0.txt 20 | # 21 | # Unless required by applicable law or agreed to in writing, software 22 | # distributed under the License is distributed on an "AS IS" BASIS, 23 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | # See the License for the specific language governing permissions and 25 | # limitations under the License. 26 | # 27 | ########################################################################### 28 | 29 | include(CMakeParseArguments) 30 | 31 | #.rst: 32 | # Global Variables 33 | # ^^^^^^^^^^^^^^^^ 34 | 35 | #.rst: 36 | # .. cmake:variable:: EXTERNAL_PROJECT_DIR 37 | # 38 | # This variable describes the directory in which external project files 39 | # matching ``.cmake`` expression are globbed. 40 | # 41 | if(NOT EXISTS "${EXTERNAL_PROJECT_DIR}") 42 | set(EXTERNAL_PROJECT_DIR ${CMAKE_SOURCE_DIR}/SuperBuild) 43 | endif() 44 | 45 | #.rst: 46 | # .. cmake:variable:: EXTERNAL_PROJECT_ADDITIONAL_DIR 47 | # 48 | # If set, this variable represents an other directory in which external project files 49 | # are searched for if not already found in ``EXTERNAL_PROJECT_DIR``. 50 | 51 | #.rst: 52 | # .. cmake:variable:: EXTERNAL_PROJECT_ADDITIONAL_DIRS 53 | # 54 | # If set, this variable represents additional directories in which external project files 55 | # are searched for if not already found in ``EXTERNAL_PROJECT_DIR`` and 56 | # ``EXTERNAL_PROJECT_ADDITIONAL_DIR``. 57 | 58 | #.rst: 59 | # .. cmake:variable:: EXTERNAL_PROJECT_FILE_PREFIX 60 | # 61 | # This variable describes the prefix of the external project files looked up in 62 | # ``EXTERNAL_PROJECT_DIR``. It defaults to ``External_``. 63 | # 64 | if(NOT DEFINED EXTERNAL_PROJECT_FILE_PREFIX) 65 | set(EXTERNAL_PROJECT_FILE_PREFIX "External_") 66 | endif() 67 | 68 | #.rst: 69 | # .. cmake:variable:: SUPERBUILD_TOPLEVEL_PROJECT 70 | # 71 | # This variable can be set to explicitly identify the name of the top-level project. 72 | # If not set, it default to the value of ``CMAKE_PROJECT_NAME``. 73 | if(NOT DEFINED SUPERBUILD_TOPLEVEL_PROJECT) 74 | if(NOT DEFINED CMAKE_PROJECT_NAME) 75 | message(FATAL_ERROR "Failed to initialize variable SUPERBUILD_TOPLEVEL_PROJECT. Variable CMAKE_PROJECT_NAME is not defined.") 76 | endif() 77 | set(SUPERBUILD_TOPLEVEL_PROJECT ${CMAKE_PROJECT_NAME}) 78 | endif() 79 | 80 | #.rst: 81 | # .. cmake:variable:: EP_LIST_SEPARATOR 82 | # 83 | # This variable is used to separate list items when passed in various external project 84 | # ``..._COMMAND`` options. 85 | # 86 | # If defaults to ``^^``. 87 | if(NOT DEFINED EP_LIST_SEPARATOR) 88 | set(EP_LIST_SEPARATOR "^^") 89 | endif() 90 | 91 | 92 | #.rst: 93 | # .. cmake:variable:: EP_GIT_PROTOCOL 94 | # 95 | # The value of this variable is controlled by the option ``_USE_GIT_PROTOCOL`` 96 | # automatically defined by including this CMake module. Setting this option allows to update the value of 97 | # ``EP_GIT_PROTOCOL`` variable. 98 | # 99 | # If enabled, the variable ``EP_GIT_PROTOCOL`` is set to ``git``. Otherwise, it is set to ``https``. 100 | # The option is enabled by default. 101 | # 102 | # The variable ``EP_GIT_PROTOCOL`` can be used when adding external project. For example: 103 | # 104 | # .. code-block:: cmake 105 | # 106 | # ExternalProject_Add(${proj} 107 | # ${${proj}_EP_ARGS} 108 | # GIT_REPOSITORY "${EP_GIT_PROTOCOL}://github.com/Foo/Foo.git" 109 | # [...] 110 | # ) 111 | # 112 | option(${SUPERBUILD_TOPLEVEL_PROJECT}_USE_GIT_PROTOCOL "If behind a firewall turn this off to use https instead." ON) 113 | set(EP_GIT_PROTOCOL "git") 114 | if(NOT ${SUPERBUILD_TOPLEVEL_PROJECT}_USE_GIT_PROTOCOL) 115 | set(EP_GIT_PROTOCOL "https") 116 | endif() 117 | 118 | # Compute -G arg for configuring external projects with the same CMake generator: 119 | if(CMAKE_EXTRA_GENERATOR) 120 | set(EP_CMAKE_GENERATOR "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") 121 | else() 122 | set(EP_CMAKE_GENERATOR "${CMAKE_GENERATOR}") 123 | endif() 124 | set(EP_CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}") 125 | set(EP_CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") 126 | 127 | #.rst: 128 | # Functions 129 | # ^^^^^^^^^ 130 | 131 | #.rst: 132 | # .. cmake:function:: mark_as_superbuild 133 | # 134 | # .. code-block:: cmake 135 | # 136 | # mark_as_superbuild([:] [[:] [...]]) 137 | # 138 | # .. code-block:: cmake 139 | # 140 | # mark_as_superbuild( 141 | # VARS [:] [[:] [...]] 142 | # [PROJECTS [ [...]] | ALL_PROJECTS] 143 | # [LABELS [ [...]]] 144 | # ) 145 | # 146 | # .. code-block:: cmake 147 | # 148 | # PROJECTS corresponds to a list of that will be added using 'ExternalProject_Add' function. 149 | # If not specified and called within a project file, it defaults to the value of 'SUPERBUILD_TOPLEVEL_PROJECT'. 150 | # If instead 'ALL_PROJECTS' is specified, the variables and labels will be passed to all projects. 151 | # 152 | # VARS is an expected list of variables specified as : to pass to 153 | # 154 | # 155 | # LABELS is an optional list of label to associate with the variable names specified using 'VARS' and passed to 156 | # the as CMake CACHE args of the form: 157 | # -D_EP_LABEL_=;[...] 158 | # -D_EP_LABEL_=;[...] 159 | # 160 | function(mark_as_superbuild) 161 | set(options ALL_PROJECTS CMAKE_CMD) 162 | set(oneValueArgs) 163 | set(multiValueArgs VARS PROJECTS LABELS) 164 | cmake_parse_arguments(_sb "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 165 | 166 | set(_vars ${_sb_UNPARSED_ARGUMENTS}) 167 | 168 | set(_named_parameters_expected 0) 169 | if(_sb_PROJECTS OR _sb_ALL_PROJECTS OR _sb_LABELS OR _sb_VARS) 170 | set(_named_parameters_expected 1) 171 | set(_vars ${_sb_VARS}) 172 | endif() 173 | 174 | if(_named_parameters_expected AND _sb_UNPARSED_ARGUMENTS) 175 | message(FATAL_ERROR "Arguments '${_sb_UNPARSED_ARGUMENTS}' should be associated with VARS parameter !") 176 | endif() 177 | 178 | if(_sb_PROJECTS AND _sb_ALL_PROJECTS) 179 | message(FATAL_ERROR "Arguments 'PROJECTS' and 'ALL_PROJECTS' are mutually exclusive !") 180 | endif() 181 | 182 | foreach(var ${_vars}) 183 | set(_type_specified 0) 184 | if(var MATCHES ":") 185 | set(_type_specified 1) 186 | endif() 187 | # XXX Display warning with variable type is also specified for cache variable. 188 | set(_var ${var}) 189 | if(NOT _type_specified) 190 | get_property(_type_set_in_cache CACHE ${_var} PROPERTY TYPE SET) 191 | set(_var_name ${_var}) 192 | set(_var_type "STRING") 193 | if(_type_set_in_cache) 194 | get_property(_var_type CACHE ${_var_name} PROPERTY TYPE) 195 | endif() 196 | set(_var ${_var_name}:${_var_type}) 197 | endif() 198 | list(APPEND _vars_with_type ${_var}) 199 | endforeach() 200 | 201 | if(_sb_ALL_PROJECTS) 202 | set(optional_arg_ALL_PROJECTS "ALL_PROJECTS") 203 | else() 204 | set(optional_arg_ALL_PROJECTS PROJECTS ${_sb_PROJECTS}) 205 | endif() 206 | 207 | _sb_append_to_cmake_args( 208 | VARS ${_vars_with_type} LABELS ${_sb_LABELS} ${optional_arg_ALL_PROJECTS}) 209 | endfunction() 210 | 211 | # 212 | # _sb_extract_varname_and_vartype( []) 213 | # 214 | # corresponds to variable name and variable type passed as ":" 215 | # 216 | # will be set to "" 217 | # 218 | # is an optional variable name that will be set to "" 219 | # 220 | function(_sb_extract_varname_and_vartype cmake_varname_and_type varname_var) 221 | set(_vartype_var "${ARGV2}") 222 | string(REPLACE ":" ";" varname_and_vartype ${cmake_varname_and_type}) 223 | list(GET varname_and_vartype 0 _varname) 224 | list(GET varname_and_vartype 1 _vartype) 225 | set(${varname_var} ${_varname} PARENT_SCOPE) 226 | if(_vartype_var MATCHES ".+") 227 | set(${_vartype_var} ${_vartype} PARENT_SCOPE) 228 | endif() 229 | endfunction() 230 | 231 | 232 | function(_sb_list_to_string separator input_list output_string_var) 233 | set(_string "") 234 | # Get list length 235 | list(LENGTH input_list list_length) 236 | # If the list has 0 or 1 element, there is no need to loop over. 237 | if(list_length LESS 2) 238 | set(_string "${input_list}") 239 | else() 240 | math(EXPR last_element_index "${list_length} - 1") 241 | foreach(index RANGE ${last_element_index}) 242 | # Get current item_value 243 | list(GET input_list ${index} item_value) 244 | if(NOT item_value STREQUAL "") 245 | # .. and append non-empty value to output string 246 | set(_string "${_string}${item_value}") 247 | # Append separator if current element is NOT the last one. 248 | if(NOT index EQUAL last_element_index) 249 | set(_string "${_string}${separator}") 250 | endif() 251 | endif() 252 | endforeach() 253 | endif() 254 | set(${output_string_var} ${_string} PARENT_SCOPE) 255 | endfunction() 256 | 257 | # 258 | # _sb_cmakevar_to_cmakearg( [ []]) 259 | # 260 | # corresponds to variable name and variable type passed as ":" 261 | # 262 | # is a variable name that will be set to "-D:=${}" 263 | # 264 | # is set to either TRUE or FALSE. 265 | # FALSE means that the value does NOT reference ${CMAKE_CFG_INTDIR} and 266 | # the generated cmake argument should be passed to ExternalProject_Add as CMAKE_CACHE_ARGS. 267 | # TRUEmeans that the value does reference ${CMAKE_CFG_INTDIR} and 268 | # the generated cmake argument should be passed to ExternalProject_Add as CMAKE_ARGS. 269 | # 270 | # is an optional variable name that will be set to "" 271 | # 272 | # is an optional variable name that will be set to "" 273 | # 274 | function(_sb_cmakevar_to_cmakearg cmake_varname_and_type cmake_arg_var has_cfg_intdir_var) 275 | set(_varname_var "${ARGV3}") 276 | set(_vartype_var "${ARGV4}") 277 | 278 | _sb_extract_varname_and_vartype(${cmake_varname_and_type} _varname _vartype) 279 | 280 | set(_var_value "${${_varname}}") 281 | 282 | # Use cache value unless it is INTERNAL 283 | if(_vartype STREQUAL "INTERNAL") 284 | set(_vartype "STRING") 285 | else() 286 | get_property(_value_set_in_cache CACHE ${_varname} PROPERTY VALUE SET) 287 | if(_value_set_in_cache) 288 | get_property(_var_value CACHE ${_varname} PROPERTY VALUE) 289 | endif() 290 | endif() 291 | 292 | set(_has_cfg_intdir FALSE) 293 | if(CMAKE_CONFIGURATION_TYPES) 294 | string(FIND "${_var_value}" ${CMAKE_CFG_INTDIR} _index) 295 | if(NOT _index EQUAL -1) 296 | # Separate list item with 297 | _sb_list_to_string(${EP_LIST_SEPARATOR} "${_var_value}" _var_value) 298 | set(_has_cfg_intdir TRUE) 299 | endif() 300 | endif() 301 | 302 | if(NOT _has_cfg_intdir) 303 | string(REPLACE "\"" "\\\"" _var_value "${_var_value}") 304 | endif() 305 | 306 | set(${cmake_arg_var} -D${_varname}:${_vartype}=${_var_value} PARENT_SCOPE) 307 | set(${has_cfg_intdir_var} ${_has_cfg_intdir} PARENT_SCOPE) 308 | 309 | if(_varname_var MATCHES ".+") 310 | set(${_varname_var} ${_varname} PARENT_SCOPE) 311 | endif() 312 | if(_vartype_var MATCHES ".+") 313 | set(${_vartype_var} ${_vartype} PARENT_SCOPE) 314 | endif() 315 | endfunction() 316 | 317 | set(_ALL_PROJECT_IDENTIFIER "ALLALLALL") 318 | 319 | # 320 | # _sb_append_to_cmake_args( 321 | # [VARS : [: [...]]] 322 | # [PROJECTS [ [...]] | ALL_PROJECTS] 323 | # [LABELS [ [...]]] 324 | # ) 325 | # 326 | # PROJECTS corresponds to a list of that will be added using 'ExternalProject_Add' function. 327 | # If not specified and called within a project file, it defaults to the value of 'SUPERBUILD_TOPLEVEL_PROJECT'. 328 | # If instead 'ALL_PROJECTS' is specified, the variables and labels will be passed to all projects. 329 | # 330 | # VARS is an expected list of variables specified as : to pass to 331 | # 332 | # 333 | # LABELS is an optional list of label to associate with the variable names specified using 'VARS' and passed to 334 | # the as CMake CACHE args of the form: 335 | # -D_EP_LABEL_=;[...] 336 | # -D_EP_LABEL_=;[...] 337 | # 338 | function(_sb_append_to_cmake_args) 339 | set(options ALL_PROJECTS) 340 | set(oneValueArgs) 341 | set(multiValueArgs VARS PROJECTS LABELS) 342 | cmake_parse_arguments(_sb "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 343 | 344 | if(NOT _sb_PROJECTS AND NOT _sb_ALL_PROJECTS) 345 | set(_sb_PROJECTS ${SUPERBUILD_TOPLEVEL_PROJECT}) 346 | endif() 347 | 348 | if(_sb_ALL_PROJECTS) 349 | set(_sb_PROJECTS ${_ALL_PROJECT_IDENTIFIER}) 350 | endif() 351 | 352 | foreach(_sb_PROJECT ${_sb_PROJECTS}) 353 | 354 | set(_ep_varnames "") 355 | foreach(varname_and_vartype ${_sb_VARS}) 356 | if(NOT TARGET ${_sb_PROJECT}) 357 | set_property(GLOBAL APPEND PROPERTY ${_sb_PROJECT}_EP_CMAKE_ARGS ${varname_and_vartype}) 358 | _sb_extract_varname_and_vartype(${varname_and_vartype} _varname) 359 | else() 360 | message(FATAL_ERROR "Function _sb_append_to_cmake_args not allowed because project '${_sb_PROJECT}' already added !") 361 | endif() 362 | list(APPEND _ep_varnames ${_varname}) 363 | endforeach() 364 | 365 | if(_sb_LABELS) 366 | set_property(GLOBAL APPEND PROPERTY ${_sb_PROJECT}_EP_LABELS ${_sb_LABELS}) 367 | foreach(label ${_sb_LABELS}) 368 | set_property(GLOBAL APPEND PROPERTY ${_sb_PROJECT}_EP_LABEL_${label} ${_ep_varnames}) 369 | endforeach() 370 | endif() 371 | endforeach() 372 | endfunction() 373 | 374 | #.rst: 375 | # .. cmake:function:: ExternalProject_DeclareLabels 376 | # 377 | # .. code-block:: cmake 378 | # 379 | # ExternalProject_DeclareLabels( 380 | # [PROJECTS [ [...]] | ALL_PROJECTS] 381 | # LABELS [ [...]] 382 | # ) 383 | # 384 | # .. code-block:: cmake 385 | # 386 | # PROJECTS corresponds to a list of that will be added using 'ExternalProject_Add' function. 387 | # If not specified and called within a project file, it defaults to the value of 'SUPERBUILD_TOPLEVEL_PROJECT'. 388 | # If instead 'ALL_PROJECTS' is specified, the variables and labels will be passed to all projects. 389 | # 390 | # LABELS is a list of label to pass to the as CMake CACHE args of the 391 | # form -D_EP_LABEL_