Mercurial > hg > orthanc-stone
comparison Applications/Samples/CMakeLists.txt @ 504:7cdb4634846c
Merge
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 26 Feb 2019 21:15:20 +0100 |
parents | 5055031f4a06 |
children | 801d2697a1b1 |
comparison
equal
deleted
inserted
replaced
460:4d8ac609fc33 | 504:7cdb4634846c |
---|---|
1 # Usage (Linux): | 1 # Usage: see README file |
2 # to build the WASM samples | |
3 # source ~/Downloads/emsdk/emsdk_env.sh && cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release -DSTONE_SOURCES_DIR=$currentDir/../../../orthanc-stone -DORTHANC_FRAMEWORK_SOURCE=path -DORTHANC_FRAMEWORK_ROOT=$currentDir/../../../orthanc -DALLOW_DOWNLOADS=ON .. -DENABLE_WASM=ON | |
4 # to build the Qt samples | |
5 | 2 |
6 cmake_minimum_required(VERSION 2.8.3) | 3 cmake_minimum_required(VERSION 2.8.3) |
4 | |
5 # Automatically link Qt executables to qtmain target on Windows | |
6 # ("OLD" == do not link) | |
7 if(POLICY CMP0020) | |
8 cmake_policy(SET CMP0020 OLD) | |
9 endif() | |
10 | |
11 # Only interpret if() arguments as variables or keywords when unquoted. | |
12 # NEW = do NOT dereference *quoted* variables | |
13 if(POLICY CMP0054) | |
14 cmake_policy(SET CMP0054 NEW) | |
15 endif() | |
16 | |
7 project(OrthancStone) | 17 project(OrthancStone) |
8 | 18 |
9 include(../../Resources/CMake/OrthancStoneParameters.cmake) | 19 include(../../Resources/CMake/OrthancStoneParameters.cmake) |
10 | 20 |
11 #set(ENABLE_DCMTK ON) | 21 #set(ENABLE_DCMTK ON) |
12 | 22 |
13 set(ENABLE_SDL OFF CACHE BOOL "Target SDL Native application") | 23 set(ENABLE_SDL OFF CACHE BOOL "Target SDL Native application") |
14 set(ENABLE_QT OFF CACHE BOOL "Target Qt Native application") | 24 set(ENABLE_QT OFF CACHE BOOL "Target Qt Native application") |
15 set(ENABLE_WASM OFF CACHE BOOL "Target WASM application") | 25 set(ENABLE_WASM OFF CACHE BOOL "Target WASM application") |
26 | |
27 # TODO: replace or compute STONE_SOURCES_DIR from CMAKE_CURRENT_LIST_FILE | |
16 | 28 |
17 if (ENABLE_WASM) | 29 if (ENABLE_WASM) |
18 ##################################################################### | 30 ##################################################################### |
19 ## Configuration of the Emscripten compiler for WebAssembly target | 31 ## Configuration of the Emscripten compiler for WebAssembly target |
20 ##################################################################### | 32 ##################################################################### |
21 | 33 |
22 set(WASM_FLAGS "-s WASM=1") | 34 set(WASM_FLAGS "-s WASM=1 -O0 -g0") |
35 message("*****************************************************************************") | |
36 message("WARNING: optimizations are disabled in emcc!!! Enable them for production use") | |
37 message("*****************************************************************************") | |
23 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") | 38 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") |
24 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") | 39 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") |
25 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | 40 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") |
26 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Applications/Samples/samples-library.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmDelayedCallExecutor.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") | 41 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmDelayedCallExecutor.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") |
27 | 42 |
28 # Handling of memory | 43 # Handling of memory |
29 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize | 44 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize |
30 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB | 45 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB |
31 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='\"${WASM_MODULE_NAME}\"' -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912 -s TOTAL_STACK=128000000") # 512MB + resize | 46 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='\"${WASM_MODULE_NAME}\"' -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912 -s TOTAL_STACK=128000000") # 512MB + resize |
63 | 78 |
64 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")") | 79 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")") |
65 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") | 80 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") |
66 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") | 81 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") |
67 | 82 |
68 | |
69 ##################################################################### | 83 ##################################################################### |
70 ## Build a static library containing the Orthanc Stone framework | 84 ## Build a static library containing the Orthanc Stone framework |
71 ##################################################################### | 85 ##################################################################### |
72 | |
73 | 86 |
74 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options) | 87 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options) |
75 | 88 |
76 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) | 89 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) |
77 | 90 |
130 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} | 143 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} |
131 ${SAMPLE_APPLICATIONS_SOURCES} | 144 ${SAMPLE_APPLICATIONS_SOURCES} |
132 ) | 145 ) |
133 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) | 146 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) |
134 target_link_libraries(${Target} OrthancStone) | 147 target_link_libraries(${Target} OrthancStone) |
148 | |
149 if (ENABLE_QT AND (CMAKE_SYSTEM_NAME STREQUAL "Windows")) | |
150 message("(ENABLE_QT and (CMAKE_SYSTEM_NAME matches \"Windows\")) is true") | |
151 add_custom_command( | |
152 TARGET ${Target} POST_BUILD | |
153 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:${Target}> | |
154 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:${Target}> | |
155 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:${Target}> | |
156 ) | |
157 endif() | |
135 endmacro() | 158 endmacro() |
136 | 159 |
137 #BuildSingleFileSample(OrthancStoneEmpty EmptyApplication.h 1) | 160 #BuildSingleFileSample(OrthancStoneEmpty EmptyApplication.h 1) |
138 #BuildSingleFileSample(OrthancStoneTestPattern TestPatternApplication.h 2) | 161 #BuildSingleFileSample(OrthancStoneTestPattern TestPatternApplication.h 2) |
139 BuildSingleFileSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) | 162 BuildSingleFileSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) |
146 | 169 |
147 ##### SimpleViewer sample (Qt and WASM only) ####### | 170 ##### SimpleViewer sample (Qt and WASM only) ####### |
148 | 171 |
149 if (ENABLE_QT OR ENABLE_WASM) | 172 if (ENABLE_QT OR ENABLE_WASM) |
150 | 173 |
174 # GenerateCodeFromFlatBufferSchema("${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/ApplicationCommands.fbs") | |
175 | |
176 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES ${FLATC_AUTOGENERATED_SOURCES}) | |
177 message(STATUS "SIMPLE_VIEWER_APPLICATION_SOURCES = ${SIMPLE_VIEWER_APPLICATION_SOURCES}") | |
178 message(STATUS "FLATC_AUTOGENERATED_SOURCES = ${FLATC_AUTOGENERATED_SOURCES}") | |
179 | |
151 if (ENABLE_QT) | 180 if (ENABLE_QT) |
152 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES | 181 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES |
153 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp | 182 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp |
154 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui | 183 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui |
155 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/mainQt.cpp | 184 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/mainQt.cpp |