Mercurial > hg > orthanc-stone
comparison Applications/Samples/CMakeLists.txt @ 518:40bb5eb247a5 bgo-commands-codegen
Reverted a couple of files to AM version (wrong changes on my end)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 12 Mar 2019 09:19:06 +0100 |
parents | 801d2697a1b1 |
children | 700aa66f2f29 |
comparison
equal
deleted
inserted
replaced
517:64ee3033e1ca | 518:40bb5eb247a5 |
---|---|
1 # Usage: see README file | 1 # Usage (Linux): |
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 | |
2 | 5 |
3 cmake_minimum_required(VERSION 2.8.3) | 6 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 | |
17 project(OrthancStone) | 7 project(OrthancStone) |
18 | 8 |
19 include(../../Resources/CMake/OrthancStoneParameters.cmake) | 9 include(../../Resources/CMake/OrthancStoneParameters.cmake) |
20 | 10 |
21 #set(ENABLE_DCMTK ON) | 11 #set(ENABLE_DCMTK ON) |
22 | 12 |
23 set(ENABLE_SDL OFF CACHE BOOL "Target SDL Native application") | 13 set(ENABLE_SDL OFF CACHE BOOL "Target SDL Native application") |
24 set(ENABLE_QT OFF CACHE BOOL "Target Qt Native application") | 14 set(ENABLE_QT OFF CACHE BOOL "Target Qt Native application") |
25 set(ENABLE_WASM OFF CACHE BOOL "Target WASM application") | 15 set(ENABLE_WASM OFF CACHE BOOL "Target WASM application") |
26 | |
27 # TODO: replace or compute STONE_SOURCES_DIR from CMAKE_CURRENT_LIST_FILE | |
28 | 16 |
29 if (ENABLE_WASM) | 17 if (ENABLE_WASM) |
30 ##################################################################### | 18 ##################################################################### |
31 ## Configuration of the Emscripten compiler for WebAssembly target | 19 ## Configuration of the Emscripten compiler for WebAssembly target |
32 ##################################################################### | 20 ##################################################################### |
33 | 21 |
34 set(WASM_FLAGS "-s WASM=1 -O0 -g0") | 22 set(WASM_FLAGS "-s WASM=1") |
35 message("*****************************************************************************") | 23 set(WASM_FLAGS "${WASM_FLAGS} -s STRICT=1") # drops support for all deprecated build options |
36 message("WARNING: optimizations are disabled in emcc!!! Enable them for production use") | 24 set(WASM_FLAGS "${WASM_FLAGS} -s FILESYSTEM=1") # if we don't include it, gen_uuid.c fails to build because srand, getpid(), ... are not defined |
37 message("*****************************************************************************") | 25 set(WASM_FLAGS "${WASM_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0") # actually enable exception catching |
26 set(WASM_FLAGS "${WASM_FLAGS} -s ERROR_ON_MISSING_LIBRARIES=1") | |
27 | |
28 if (CMAKE_BUILD_TYPE MATCHES DEBUG) | |
29 set(WASM_FLAGS "${WASM_FLAGS} -g4") # generate debug information | |
30 set(WASM_FLAGS "${WASM_FLAGS} -s ASSERTIONS=2") # more runtime checks | |
31 else() | |
32 set(WASM_FLAGS "${WASM_FLAGS} -Os") # optimize for web (speed and size) | |
33 endif() | |
34 | |
38 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") | 35 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") |
36 | |
39 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") | 37 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") |
40 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | 38 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") |
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\"]'") | 39 |
42 | 40 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WASM_FLAGS}") # not always clear which flags are for the compiler and which one are for the linker -> pass them all to the linker too |
43 # Handling of memory | 41 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Applications/Samples/samples-library.js") |
44 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize | 42 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js") |
45 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB | 43 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmDelayedCallExecutor.js") |
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 | 44 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js") |
47 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize | 45 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") |
48 | 46 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='\"${WASM_MODULE_NAME}\"'") |
49 # To debug exceptions | 47 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") |
50 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2") | 48 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") |
49 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_STACK=128000000") | |
51 | 50 |
52 add_definitions(-DORTHANC_ENABLE_WASM=1) | 51 add_definitions(-DORTHANC_ENABLE_WASM=1) |
53 set(ORTHANC_SANDBOXED ON) | 52 set(ORTHANC_SANDBOXED ON) |
54 | 53 |
55 elseif (ENABLE_QT OR ENABLE_SDL) | 54 elseif (ENABLE_QT OR ENABLE_SDL) |
78 | 77 |
79 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")") | 78 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")") |
80 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") | 79 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") |
81 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") | 80 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") |
82 | 81 |
82 | |
83 ##################################################################### | 83 ##################################################################### |
84 ## Build a static library containing the Orthanc Stone framework | 84 ## Build a static library containing the Orthanc Stone framework |
85 ##################################################################### | 85 ##################################################################### |
86 | |
86 | 87 |
87 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options) | 88 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options) |
88 | 89 |
89 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) | 90 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) |
90 | 91 |
143 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} | 144 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} |
144 ${SAMPLE_APPLICATIONS_SOURCES} | 145 ${SAMPLE_APPLICATIONS_SOURCES} |
145 ) | 146 ) |
146 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) | 147 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) |
147 target_link_libraries(${Target} OrthancStone) | 148 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() | |
158 endmacro() | 149 endmacro() |
159 | 150 |
160 #BuildSingleFileSample(OrthancStoneEmpty EmptyApplication.h 1) | 151 #BuildSingleFileSample(OrthancStoneEmpty EmptyApplication.h 1) |
161 #BuildSingleFileSample(OrthancStoneTestPattern TestPatternApplication.h 2) | 152 #BuildSingleFileSample(OrthancStoneTestPattern TestPatternApplication.h 2) |
162 BuildSingleFileSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) | 153 BuildSingleFileSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) |
169 | 160 |
170 ##### SimpleViewer sample (Qt and WASM only) ####### | 161 ##### SimpleViewer sample (Qt and WASM only) ####### |
171 | 162 |
172 if (ENABLE_QT OR ENABLE_WASM) | 163 if (ENABLE_QT OR ENABLE_WASM) |
173 | 164 |
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 | |
180 if (ENABLE_QT) | 165 if (ENABLE_QT) |
181 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES | 166 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES |
182 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp | 167 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp |
183 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui | 168 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui |
184 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/mainQt.cpp | 169 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/mainQt.cpp |