Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ wiShaderdump.h

# vscode
.vscode/settings.json
/.vscode/

# PlayStation
*.tlog
Expand Down
32 changes: 27 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,25 @@ option(USE_LIBCXX "Link WickedEngine to llvm libc++ library - only available wit
option(WICKED_EDITOR "Build WickedEngine editor" ON)
option(WICKED_TESTS "Build WickedEngine tests" ON)
option(WICKED_IMGUI_EXAMPLE "Build WickedEngine imgui example" ON)
option(WICKED_ENABLE_IPO "Enable IPO/LTO in non-debug builds" NO)
option(WICKED_EMBED_SHADERS "Embed shaders into the library" NO)
option(WICKED_ENABLE_IPO "Enable IPO/LTO in non-debug builds" OFF)
option(WICKED_EMBED_SHADERS "Embed shaders into the library" OFF)
option(WICKED_ENABLE_RTTI "Enable RTTI" NO)
if(UNIX)
if (APPLE)
set(WICKED_TESTS OFF) # no main for macos
set(WICKED_IMGUI_EXAMPLE OFF) # no main for macos
set(WICKED_ENABLE_IPO OFF)
endif()

if(UNIX AND NOT APPLE)
option(WICKED_ENABLE_ASAN "Enable AddressSanitizer in debug builds" OFF)
option(WICKED_ENABLE_UBSAN "Enable UndefinedBehaviourSanitizer in debug builds" OFF)
option(WICKED_ENABLE_TSAN "Enable ThreadSanitizer in debug builds" OFF)
option(WICKED_ENABLE_SAN_ALWAYS "Enable the selected sanitizers in all builds, not just debug" OFF)
endif()
if(UNIX)

if(APPLE)
option(WICKED_MACOS_TEMPLATE "Build WickedEngine MacOS template" ON)
elseif(UNIX)
option(WICKED_LINUX_TEMPLATE "Build WickedEngine Linux template" ON)
elseif(WIN32)
option(WICKED_WINDOWS_TEMPLATE "Build WickedEngine Windows template" ON)
Expand Down Expand Up @@ -113,6 +122,15 @@ if (WIN32)
set(PLATFORM "Windows")
add_compile_definitions(WIN32=1)
add_compile_definitions(_HAS_EXCEPTIONS=0)
elseif (APPLE)
# set(CMAKE_C_COMPILER /opt/homebrew/opt/llvm/bin/clang)
# set(CMAKE_CXX_COMPILER /opt/homebrew/opt/llvm/bin/clang++)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_LINKER ld64.lld)
set(PLATFORM "MacOS")
add_compile_definitions(MACOS=1)
elseif (UNIX)
set(PLATFORM "SDL2")
add_compile_definitions(SDL2=1)
Expand Down Expand Up @@ -147,7 +165,7 @@ else()
# security checks disabled in Release:
$<$<CONFIG:Release>:-fno-stack-protector>
$<$<CONFIG:Release>:-fcf-protection=none>
$<$<AND:$<CONFIG:Release>,$<NOT:$<PLATFORM_ID:Windows>>>:-fno-stack-clash-protection> # not supported on Windows
$<$<AND:$<CONFIG:Release>,$<NOT:$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Darwin>>>>:-fno-stack-clash-protection> # not supported on Windows or macOS
$<$<CONFIG:Release>:-fno-stack-check>
$<$<AND:$<CONFIG:Release>,$<NOT:$<PLATFORM_ID:Windows>>>:-fno-asynchronous-unwind-tables> # seems to crash LUA evaluation on Windows
)
Expand Down Expand Up @@ -206,6 +224,10 @@ if (WICKED_LINUX_TEMPLATE)
add_subdirectory(Samples/Template_Linux)
endif()

if (WICKED_MACOS_TEMPLATE)
add_subdirectory(Samples/Template_MacOS)
endif()

if (WICKED_WINDOWS_TEMPLATE)
add_subdirectory(Samples/Template_Windows)
endif()
24 changes: 23 additions & 1 deletion Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ string(REGEX REPLACE "([.+?*])" "\\\\\\1" SDIR "${CMAKE_CURRENT_SOURCE_DIR}")
file(GLOB SOURCE_FILES CONFIGURE_DEPENDS *.cpp)
list(FILTER SOURCE_FILES EXCLUDE REGEX ${SDIR}/main_.*)
list(FILTER SOURCE_FILES EXCLUDE REGEX ${SDIR}/stdafx.*)
list(APPEND SOURCE_FILES main_${PLATFORM}.cpp)

if (APPLE)
list(APPEND SOURCE_FILES main_MacOS.mm)
# The project PCH doesn't work with objective C, so disable it for the mm files.
set_source_files_properties(main_MacOS.mm PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
else()
list(APPEND SOURCE_FILES main_${PLATFORM}.cpp)
endif()

if (WIN32)
list (APPEND SOURCE_FILES
Expand All @@ -30,6 +36,22 @@ if (WIN32)

set_property(TARGET Editor PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
set(LIB_DXCOMPILER "dxcompiler.dll")
elseif (APPLE)
add_executable(Editor ${SOURCE_FILES})

find_library(APPKIT_FRAMEWORK AppKit REQUIRED)

target_link_libraries(Editor PUBLIC
WickedEngine
${APPKIT_FRAMEWORK}
)
set(LIB_DXCOMPILER "libdxcompiler.dylib")

# needed for proper names in crash stacktrace
set_target_properties(Editor
PROPERTIES
ENABLE_EXPORTS ON
)
else ()
add_executable(Editor ${SOURCE_FILES})

Expand Down
11 changes: 7 additions & 4 deletions Samples/Example_ImGui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ if (WIN32)
Example_ImGui_Lib
)
set(LIB_DXCOMPILER "dxcompiler.dll")
elseif(APPLE)
# TODO
set(LIB_DXCOMPILER "dxcompiler.dylib")
else()
list(APPEND SOURCE_FILES
main_SDL2.cpp
Expand Down Expand Up @@ -76,10 +79,10 @@ else()
endif ()

if(WICKED_ENABLE_IPO)
set_target_properties(Example_ImGui PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ON
INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF
)
set_target_properties(Example_ImGui PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ON
INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF
)
endif()

if (MSVC)
Expand Down
2 changes: 2 additions & 0 deletions Samples/Example_ImGui_Docking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ if (WIN32)
Example_ImGui_Docking_Lib
)
set(LIB_DXCOMPILER "dxcompiler.dll")
elseif(APPLE)
set(LIB_DXCOMPILER "dxcompiler.dylib")
else()
list(APPEND SOURCE_FILES
main_SDL2.cpp
Expand Down
46 changes: 46 additions & 0 deletions Samples/Template_MacOS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.19)
project(Template_MacOS)

# if the engine is installed system-wise,
# you can set INSTALLED_ENGINE to ON
# moving your project folder wherever you want
set(INSTALLED_ENGINE OFF)
# you may also want to remove the copy mechanism of the startup.lua file

if (${INSTALLED_ENGINE})
find_package(WickedEngine REQUIRED)
endif()

set(SOURCE_FILES
main.mm
)

set(LIB_DXCOMPILER "libdxcompiler.dylib")

add_executable(Template_MacOS ${SOURCE_FILES})

target_link_libraries(Template_MacOS PUBLIC
$<IF:$<BOOL:${INSTALLED_ENGINE}>,WickedEngine::WickedEngine,WickedEngine>
)

if(WICKED_ENABLE_IPO)
set_target_properties(Template_MacOS PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ON
INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF
)
endif()

if (${INSTALLED_ENGINE})
get_property(LIBDXCOMPILER_PATH
TARGET WickedEngine::dxcompiler
PROPERTY IMPORTED_LOCATION)
get_filename_component(WICKED_LIBFOLDER ${LIBDXCOMPILER_PATH} DIRECTORY)
else()
set(LIBDXCOMPILER_PATH "${WICKED_ROOT_DIR}/WickedEngine/${LIB_DXCOMPILER}")
endif()
message("libdxcompiler found at ${LIBDXCOMPILER_PATH}")

add_custom_command(
TARGET Template_MacOS POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBDXCOMPILER_PATH} ${CMAKE_CURRENT_BINARY_DIR}
)
3 changes: 3 additions & 0 deletions Samples/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ if (WIN32)
)

set(LIB_DXCOMPILER "dxcompiler.dll")
elseif(APPLE)

set(LIB_DXCOMPILER "dxcompiler.dylib")
else()
list (APPEND SOURCE_FILES
main_SDL2.cpp
Expand Down
Loading
Loading