Skip to content

Commit

Permalink
use cmake targets for compilation options
Browse files Browse the repository at this point in the history
Contributes to NP-5
  • Loading branch information
jellespijker committed Jan 30, 2024
1 parent 38ca879 commit 6ffa5dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ option(ENABLE_SENTRY "Send crash data via Sentry" OFF)
option(ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS "Enable more optimization flags" ON)
option(USE_SYSTEM_LIBS "Use the system libraries if available" OFF)
option(OLDER_APPLE_CLANG "Apple Clang <= 13 used" OFF)

option(OLDER_APPLE_CLANG "Apple Clang <= 13 used" OFF)
option(ENABLE_THREADING "Enable threading support" ON)

if (${ENABLE_ARCUS} OR ${ENABLE_PLUGINS})
find_package(protobuf REQUIRED)
Expand Down Expand Up @@ -157,7 +156,9 @@ set(engine_SRCS # Except main.cpp.
)

add_library(_CuraEngine STATIC ${engine_SRCS} ${engine_PB_SRCS})
#use_threads(_CuraEngine)
if (ENABLE_THREADING)
use_threads(_CuraEngine)
endif ()

target_include_directories(_CuraEngine
PUBLIC
Expand Down Expand Up @@ -252,7 +253,15 @@ else ()
endif ()
endif (NOT WIN32)

#use_threads(CuraEngine)
if (ENABLE_THREADING)
use_threads(CuraEngine)
endif ()

if (CMAKE_CXX_PLATFORM_ID STREQUAL "emscripten")
message(STATUS "Building for Emscripten")
target_link_options(_CuraEngine PUBLIC -Wno-unused-command-line-argument -sINVOKE_RUN=0 -sEXPORT_NAME=CuraEngine -sEXPORTED_RUNTIME_METHODS=[callMain,FS] -sFORCE_FILESYSTEM=1 -sALLOW_MEMORY_GROWTH=1 -sEXPORT_ES6=1 -sMODULARIZE=1 -sSINGLE_FILE=1 -sENVIRONMENT=worker)
endif ()

target_link_libraries(CuraEngine PRIVATE
_CuraEngine
$<$<BOOL:${ENABLE_SENTRY}>:sentry::sentry>
Expand Down
4 changes: 1 addition & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def generate(self):
tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "14"
tc.variables["ENABLE_THREADING"] = not (self.settings.arch == "wasm" and self.settings.os == "Emscripten")
if self.options.get_safe("enable_sentry", False):
tc.variables["ENABLE_SENTRY"] = True
tc.variables["SENTRY_URL"] = self.conf.get("user.curaengine:sentry_url", "", check_type=str)
Expand All @@ -147,9 +148,6 @@ def generate(self):
tc.variables["ENABLE_PLUGINS"] = self.options.enable_plugins
tc.generate()

if self.settings.arch == "wasm" and self.settings.os == "Emscripten":
self.buildenv.define("EMCC_CFLAGS", "-s FORCE_FILESYSTEM -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_ES6=1 -s EXPORT_NAME='CuraEngine' -s EXPORTED_RUNTIME_METHODS='[\"callMain\", \"FS\"]' -s INVOKE_RUN=0 -s MODULARIZE=1 -s SINGLE_FILE=1 -s ENVIRONMENT=worker -s USE_ES6_IMPORT_META=0")

for dep in self.dependencies.values():
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], self.build_folder)
Expand Down

0 comments on commit 6ffa5dc

Please sign in to comment.