metaforce/CMakeLists.txt

286 lines
12 KiB
CMake
Raw Normal View History

2017-11-14 04:54:47 +00:00
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
2017-12-19 03:05:50 +00:00
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)
2017-12-19 03:05:50 +00:00
if(APPLE AND NOT CMAKE_OSX_SYSROOT)
# If the Xcode SDK is lagging behind system version, CMake needs this done first
execute_process(COMMAND xcrun --sdk macosx --show-sdk-path
2017-12-19 03:05:50 +00:00
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
2018-10-07 02:59:17 +00:00
option(URDE_CROSSCOMPILING "Don't build tools; attempt package import" OFF)
if (URDE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING On)
endif()
2018-10-07 02:59:17 +00:00
if(CMAKE_CROSSCOMPILING)
set(HAVE_WORDS_BIGENDIAN_EXITCODE 0 CACHE INTEGER "Makes soxr happy" FORCE)
endif()
project(urde)
2017-11-13 06:19:18 +00:00
set(CMAKE_CXX_STANDARD 17)
2017-06-18 02:53:39 +00:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2017-07-03 04:48:19 +00:00
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE)
set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE)
2017-06-18 02:53:39 +00:00
2017-12-29 08:08:12 +00:00
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sanitizers-cmake/cmake" "${CMAKE_SOURCE_DIR}/cotire/CMake" ${CMAKE_MODULE_PATH})
2017-12-12 02:06:19 +00:00
find_package(Sanitizers)
# Don't cotire when using clang-cl
if(NOT MSVC OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
include(cotire)
endif()
2017-12-12 02:06:19 +00:00
2018-10-07 02:59:17 +00:00
if (NX)
set(URDE_VECTOR_ISA "neon")
else()
set(URDE_VECTOR_ISA "sse2" CACHE STRING "Vector ISA to build for (sse2, sse3, sse41, avx, avx2)")
endif()
2017-12-12 02:06:19 +00:00
if(MSVC)
if(${URDE_VECTOR_ISA} STREQUAL "avx2")
2017-12-16 01:33:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 -D__SSE4_1__=1")
2017-12-27 04:12:28 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2 -D__SSE4_1__=1")
message(STATUS "Building with AVX2 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "avx")
2017-12-16 01:33:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -D__SSE4_1__=1")
2017-12-27 04:12:28 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX -D__SSE4_1__=1")
message(STATUS "Building with AVX Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse41")
2017-12-16 01:33:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__SSE4_1__=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__SSE4_1__=1")
message(STATUS "Building with SSE4.1 Vector ISA")
else()
message(STATUS "Building with SSE2 Vector ISA")
2017-12-12 02:06:19 +00:00
endif()
2016-03-05 03:34:27 +00:00
if(${CMAKE_GENERATOR} MATCHES "Visual Studio*")
set(VS_DEFINES "/MP")
2017-12-08 02:55:12 +00:00
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT urde)
2016-03-05 03:34:27 +00:00
endif()
# Shaddup MSVC
2018-10-14 20:16:21 +00:00
add_definitions(-DUNICODE=1 -D_UNICODE=1 -D__SSE__=1
-D_CRT_SECURE_NO_WARNINGS=1 -DD_SCL_SECURE_NO_WARNINGS=1
-D_SCL_SECURE_NO_DEPRECATE=1 -D_CRT_NONSTDC_NO_WARNINGS=1
2018-12-08 06:46:17 +00:00
/IGNORE:4221 /wd4018 /wd4800 /wd4005 /wd4311 /wd4068
2018-10-14 20:16:21 +00:00
/wd4267 /wd4244 /wd4200 /wd4305 /wd4067 /wd4146 /wd4309 /wd4805
-D_ENABLE_EXTENDED_ALIGNED_STORAGE=1 ${VS_DEFINES})
2017-10-24 03:12:10 +00:00
if(WINDOWS_STORE)
2017-12-07 04:13:12 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /AI\"$ENV{PROGRAMFILES\(X86\)}/Microsoft Visual Studio/2017/Community/Common7/IDE/VC/vcpackages\" /AI\"$ENV{PROGRAMFILES\(X86\)}/Windows Kits/10/UnionMetadata\"")
set(HAVE_WORDS_BIGENDIAN_EXITCODE 0)
2017-10-24 03:12:10 +00:00
endif()
2017-03-10 18:00:40 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# Link-time Code Generation for Release builds (excluding clang-cl)
2018-05-29 03:41:28 +00:00
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy /MD")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy /MD")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG")
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "/LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endif()
else()
if(${URDE_VECTOR_ISA} STREQUAL "avx2")
2017-12-16 01:33:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
message(STATUS "Building with AVX2 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "avx")
2017-12-16 01:33:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
message(STATUS "Building with AVX Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse41")
2017-12-12 02:06:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
message(STATUS "Building with SSE4.1 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse3")
2017-12-12 02:06:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
message(STATUS "Building with SSE3 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse2")
2017-12-12 02:06:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
message(STATUS "Building with SSE2 Vector ISA")
2018-10-07 02:59:17 +00:00
elseif(${URDE_VECTOR_ISA} STREQUAL "neon")
message(STATUS "Building with NEON Vector ISA")
else()
message(STATUS "Building with x87 Vector ISA")
2017-12-12 02:06:19 +00:00
endif()
2018-12-08 01:49:15 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar -fno-exceptions -fno-rtti -Werror")
2016-01-16 06:11:57 +00:00
if(APPLE)
2016-09-30 03:33:35 +00:00
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto=thin")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -flto=thin")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -flto=thin")
2016-01-16 06:11:57 +00:00
endif()
2015-07-07 03:22:44 +00:00
endif()
2015-09-27 05:29:31 +00:00
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
2015-09-13 03:43:22 +00:00
include_directories(/usr/local/include)
2016-10-27 23:50:32 +00:00
link_directories(/usr/local/lib)
2015-09-13 03:43:22 +00:00
endif()
2016-01-16 06:11:57 +00:00
if(("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
option(USE_LD_GOLD "Link with GNU Gold and enable LTO" ON)
else()
option(USE_LD_GOLD "Link with GNU Gold and enable LTO" OFF)
endif()
if(USE_LD_GOLD AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto=thin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=thin")
message(STATUS "GNU gold linker enabled.")
else()
2016-08-23 03:12:50 +00:00
message(WARNING "GNU gold linker isn't available, using the default system linker.")
set(USE_LD_GOLD OFF)
endif()
endif()
# Add discord-rpc here
2018-10-07 02:59:17 +00:00
if(NOT GEKKO AND NOT NX)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include)
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc)
if (NOT CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/fake-prefix)
endif()
add_subdirectory(discord-rpc/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc/include)
2018-01-16 06:48:40 +00:00
endif()
add_subdirectory(nod)
set(NOD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nod/include)
2018-01-02 01:04:23 +00:00
set(HECL_DLPACKAGE ${URDE_DLPACKAGE})
2016-03-04 23:04:53 +00:00
set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hecl/extern/boo/include)
2015-11-21 01:16:07 +00:00
set(HECL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hecl/include
${CMAKE_CURRENT_SOURCE_DIR}/hecl/blender)
2015-08-18 19:45:28 +00:00
set(DATA_SPEC_LIBS RetroDataSpec amuse)
set(HECL_DATASPEC_DECLS
"/* RetroCommon specs */
2016-02-13 09:02:47 +00:00
namespace DataSpec
{
2016-03-04 23:04:53 +00:00
extern hecl::Database::DataSpecEntry SpecEntMP1;
extern hecl::Database::DataSpecEntry SpecEntMP1PC;
extern hecl::Database::DataSpecEntry SpecEntMP1ORIG;
2016-03-04 23:04:53 +00:00
extern hecl::Database::DataSpecEntry SpecEntMP2;
extern hecl::Database::DataSpecEntry SpecEntMP2PC;
extern hecl::Database::DataSpecEntry SpecEntMP2ORIG;
2016-03-04 23:04:53 +00:00
extern hecl::Database::DataSpecEntry SpecEntMP3;
extern hecl::Database::DataSpecEntry SpecEntMP3PC;
extern hecl::Database::DataSpecEntry SpecEntMP3ORIG;
}")
set(HECL_DATASPEC_PUSHES
" /* RetroCommon */
hecl::Database::DATA_SPEC_REGISTRY.reserve(9);
2016-03-04 23:04:53 +00:00
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP1);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP1PC);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP1ORIG);
2016-03-04 23:04:53 +00:00
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP2);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP2PC);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP2ORIG);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3PC);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3ORIG);")
2018-10-07 02:59:17 +00:00
add_subdirectory(hecl/shaderc)
include(hecl/ApplicationTools.cmake)
add_subdirectory(specter/shaders)
add_subdirectory(Shaders)
add_subdirectory(hecl)
2016-12-08 04:55:44 +00:00
2017-12-07 04:13:12 +00:00
if(NOT TARGET bintoc)
# Use native if cross compiling
find_package(hecl-bintoc REQUIRED)
endif()
2016-12-08 04:55:44 +00:00
if(NOT TARGET atdna)
2017-12-07 04:13:12 +00:00
# Import native atdna if cross-compiling
find_package(atdna REQUIRED)
if(NOT TARGET atdna)
message(FATAL_ERROR "atdna required for building URDE; please verify LLVM installation")
endif()
2016-12-08 04:55:44 +00:00
endif()
2016-02-23 02:34:16 +00:00
add_definitions(${BOO_SYS_DEFINES})
2016-07-17 21:24:15 +00:00
include_directories(${BOO_SYS_INCLUDES})
2016-05-03 01:23:09 +00:00
add_subdirectory(amuse)
2016-03-04 23:04:53 +00:00
add_subdirectory(specter)
set(SPECTER_INCLUDE_DIR specter/include specter/freetype2/include)
add_subdirectory(assetnameparser)
2015-10-25 20:15:24 +00:00
add_definitions(-DZE_ATHENA_TYPES=1)
2016-03-04 23:04:53 +00:00
set(ZEUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/specter/zeus/include)
include_directories(${ATHENA_INCLUDE_DIR} ${LOGVISOR_INCLUDE_DIR} ${HECL_INCLUDE_DIR}
2016-05-03 01:23:09 +00:00
${NOD_INCLUDE_DIR} ${ZEUS_INCLUDE_DIR} ${BOO_INCLUDE_DIR} ${AMUSE_INCLUDE_DIR}
2018-02-01 23:19:34 +00:00
${SPECTER_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/NESEmulator)
add_subdirectory(NESEmulator)
2015-07-07 03:22:44 +00:00
add_subdirectory(DataSpec)
2016-06-28 18:54:55 +00:00
add_subdirectory(kabufuda)
2016-12-28 18:28:50 +00:00
include_directories(${KABUFUDA_INCLUDE_DIR})
2015-11-21 01:16:07 +00:00
add_subdirectory(Editor)
2016-06-28 18:54:55 +00:00
2017-01-08 02:52:49 +00:00
add_subdirectory(jbus)
set(JBUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jbus/include)
2016-04-24 04:03:30 +00:00
set(CLIENT_SOURCES
${CMAKE_SOURCE_DIR}/Editor/ProjectResourceFactoryBase.hpp
${CMAKE_SOURCE_DIR}/Editor/ProjectResourceFactoryBase.cpp
${CMAKE_SOURCE_DIR}/Editor/ProjectResourceFactoryMP1.hpp
${CMAKE_SOURCE_DIR}/Editor/ProjectResourceFactoryMP1.cpp)
2015-07-11 22:41:10 +00:00
add_subdirectory(Runtime)
2016-03-23 20:38:01 +00:00
add_subdirectory(mpcksum)
add_subdirectory(gbalink)
2017-02-24 08:28:44 +00:00
add_subdirectory(visigen)
2015-11-20 07:33:09 +00:00
2018-05-26 21:30:19 +00:00
add_dependencies(hecl visigen)
2018-10-07 02:59:17 +00:00
if (NOT WINDOWS_STORE AND NOT NX)
find_package(Qt5Widgets)
if (Qt5Widgets_FOUND)
message(STATUS "Qt5 found, hecl-gui will be built")
2017-12-06 03:36:31 +00:00
add_subdirectory(hecl-gui)
2018-10-07 02:59:17 +00:00
else()
message(STATUS "Qt5 not found, hecl-gui will not be built")
2018-10-07 02:59:17 +00:00
endif()
2017-12-04 09:55:33 +00:00
endif()
2017-12-06 03:36:31 +00:00
2015-12-25 01:10:39 +00:00
unset(GIT_EXECUTABLE CACHE)
2015-11-20 07:33:09 +00:00
find_package(Git)
if(GIT_FOUND)
# Get the current working branch
2016-07-16 19:21:12 +00:00
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE )
2015-11-20 07:33:09 +00:00
# Get the latest abbreviated commit hash of the working branch
2016-07-16 19:21:12 +00:00
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE
GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE
GIT_COMMIT_HASH_FULL OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE
GIT_COMMIT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
message(STATUS "Unable to find GIT, commit information will not be available")
set(GIT_BRANCH "")
set(GIT_COMMIT_HASH "")
set(GIT_COMMIT_HASH_FULL "")
set(GIT_COMMIT_DATE "")
2015-11-20 07:33:09 +00:00
endif()
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_SOURCE_DIR}/version.h)