2022-07-30 12:24:03 -04:00
|
|
|
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
|
|
|
|
|
2022-10-10 14:00:32 -04:00
|
|
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build libraries static" FORCE)
|
2022-10-11 04:37:46 -04:00
|
|
|
file(READ VERSION GEODE_VERSION)
|
2022-10-11 16:38:01 -04:00
|
|
|
string(STRIP "${GEODE_VERSION}" GEODE_VERSION)
|
2022-10-05 08:41:05 -04:00
|
|
|
|
|
|
|
project(geode-sdk VERSION ${GEODE_VERSION} LANGUAGES CXX C)
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
add_library(${PROJECT_NAME} INTERFACE)
|
|
|
|
|
2022-11-16 09:41:14 -05:00
|
|
|
if (NOT DEFINED GEODE_DEBUG AND (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo))
|
|
|
|
set(GEODE_DEBUG ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# define it in command line or your project system
|
|
|
|
if (GEODE_DEBUG)
|
2022-10-12 15:07:18 -04:00
|
|
|
target_compile_definitions(${PROJECT_NAME} INTERFACE -DGEODE_DEBUG)
|
|
|
|
endif()
|
|
|
|
|
2022-10-11 04:37:46 -04:00
|
|
|
# Rerun CMake on VERSION file change
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_CONFIGURE_DEPENDS VERSION)
|
|
|
|
|
2022-07-30 12:24:03 -04:00
|
|
|
target_compile_definitions(${PROJECT_NAME} INTERFACE -DPROJECT_NAME=${CMAKE_PROJECT_NAME})
|
|
|
|
|
|
|
|
set(GEODE_CODEGEN_PATH ${CMAKE_CURRENT_BINARY_DIR}/codegenned)
|
|
|
|
set(GEODE_BIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
|
|
|
set(GEODE_LOADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/loader)
|
|
|
|
|
|
|
|
include(cmake/GeodeFile.cmake)
|
|
|
|
include(cmake/Platform.cmake)
|
|
|
|
|
|
|
|
target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp)
|
|
|
|
|
|
|
|
|
2022-11-12 09:16:46 -05:00
|
|
|
include(ExternalProject)
|
|
|
|
|
|
|
|
set(GEODE_CODEGEN_BINARY_OUT ${CMAKE_CURRENT_BINARY_DIR}/codegen)
|
|
|
|
ExternalProject_Add(CodegenProject
|
|
|
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/codegen
|
|
|
|
CMAKE_CACHE_ARGS "-DCMAKE_INSTALL_PREFIX:STRING=${GEODE_CODEGEN_BINARY_OUT}"
|
|
|
|
)
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2022-10-21 19:17:08 -04:00
|
|
|
add_custom_command(
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindings/GeometryDash.bro
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bindings/Cocos2d.bro
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bindings/Entry.bro
|
2022-11-12 09:16:46 -05:00
|
|
|
DEPENDS CodegenProject
|
|
|
|
COMMAND ${GEODE_CODEGEN_BINARY_OUT}/Codegen ${GEODE_TARGET_PLATFORM} bindings ${GEODE_CODEGEN_PATH}
|
2022-10-21 19:17:08 -04:00
|
|
|
COMMAND echo codegen > ${GEODE_CODEGEN_PATH}/.stamp
|
2022-07-30 12:24:03 -04:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMENT "Run Codegen"
|
2022-10-21 19:17:08 -04:00
|
|
|
OUTPUT ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp ${GEODE_CODEGEN_PATH}/.stamp
|
2022-07-30 12:24:03 -04:00
|
|
|
)
|
2022-10-21 19:17:08 -04:00
|
|
|
|
|
|
|
add_custom_target(CodegenRun
|
|
|
|
DEPENDS ${GEODE_CODEGEN_PATH}/.stamp
|
|
|
|
)
|
|
|
|
|
2022-07-30 12:24:03 -04:00
|
|
|
add_dependencies(${PROJECT_NAME} CodegenRun)
|
|
|
|
|
2022-08-08 14:18:09 -04:00
|
|
|
# Hacky way to supress the not generated error
|
2022-10-13 07:00:41 -04:00
|
|
|
if (NOT EXISTS ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp)
|
2022-08-08 14:18:09 -04:00
|
|
|
make_directory(${GEODE_CODEGEN_PATH})
|
2022-10-13 07:03:50 -04:00
|
|
|
make_directory(${GEODE_CODEGEN_PATH}/Geode)
|
2022-10-13 07:00:41 -04:00
|
|
|
file(TOUCH ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp)
|
2022-08-08 14:18:09 -04:00
|
|
|
endif()
|
|
|
|
|
2022-10-13 07:00:41 -04:00
|
|
|
target_sources(${PROJECT_NAME} INTERFACE ${GEODE_CODEGEN_PATH}/Geode/GeneratedSource.cpp)
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
target_include_directories(${PROJECT_NAME} INTERFACE
|
2022-10-13 07:00:41 -04:00
|
|
|
${GEODE_CODEGEN_PATH}
|
2022-07-30 12:24:03 -04:00
|
|
|
${GEODE_LOADER_PATH}/include
|
2022-10-17 08:46:36 -04:00
|
|
|
${GEODE_LOADER_PATH}/include/Geode/cocos/include
|
2022-07-30 12:24:03 -04:00
|
|
|
${GEODE_LOADER_PATH}/include/Geode/cocos/extensions
|
|
|
|
${GEODE_LOADER_PATH}/include/Geode/fmod
|
|
|
|
)
|
|
|
|
target_link_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/loader/include/link)
|
|
|
|
|
2022-11-19 13:13:11 -05:00
|
|
|
add_definitions(-DFMT_CONSTEVAL=)
|
|
|
|
|
2022-11-28 11:22:59 -05:00
|
|
|
add_subdirectory(loader/include/Geode/external/filesystem)
|
|
|
|
add_subdirectory(loader/include/Geode/external/fmt)
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} INTERFACE filesystem fmt)
|
|
|
|
|
2022-08-08 14:18:09 -04:00
|
|
|
|
2022-07-30 12:24:03 -04:00
|
|
|
if (NOT EXISTS ${GEODE_BIN_PATH})
|
|
|
|
make_directory(${GEODE_BIN_PATH})
|
|
|
|
endif()
|
|
|
|
|
2022-10-03 01:06:27 -04:00
|
|
|
if (${GEODE_LINK_NIGHTLY})
|
2022-07-30 12:24:03 -04:00
|
|
|
set(GEODE_PLATFORM_BIN_PATH ${GEODE_BIN_PATH}/nightly/${GEODE_PLATFORM_BINARY})
|
|
|
|
else()
|
|
|
|
set(GEODE_PLATFORM_BIN_PATH ${GEODE_BIN_PATH}/${PROJECT_VERSION}/${GEODE_PLATFORM_BINARY})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if (PROJECT_IS_TOP_LEVEL)
|
2022-08-08 14:18:09 -04:00
|
|
|
add_subdirectory(loader)
|
2022-07-30 12:24:03 -04:00
|
|
|
target_link_libraries(${PROJECT_NAME} INTERFACE geode-loader)
|
|
|
|
elseif(EXISTS ${GEODE_PLATFORM_BIN_PATH})
|
|
|
|
target_link_libraries(${PROJECT_NAME} INTERFACE "${GEODE_PLATFORM_BIN_PATH}")
|
2022-10-14 16:44:33 -04:00
|
|
|
target_precompile_headers(${PROJECT_NAME} INTERFACE
|
2022-10-15 22:36:21 -04:00
|
|
|
"${GEODE_LOADER_PATH}/include/Geode/DefaultInclude.hpp"
|
|
|
|
"${GEODE_LOADER_PATH}/include/Geode/Loader.hpp"
|
|
|
|
"${GEODE_LOADER_PATH}/include/Geode/UI.hpp"
|
2022-10-17 08:46:36 -04:00
|
|
|
"${GEODE_LOADER_PATH}/include/Geode/cocos/include/cocos2d.h"
|
2022-10-15 22:36:21 -04:00
|
|
|
"${GEODE_LOADER_PATH}/include/Geode/cocos/extensions/cocos-ext.h"
|
2022-10-14 16:42:35 -04:00
|
|
|
)
|
2022-07-30 12:24:03 -04:00
|
|
|
else()
|
2022-10-17 08:46:36 -04:00
|
|
|
message(FATAL_ERROR
|
2022-10-26 09:20:39 -04:00
|
|
|
"No valid loader binary to link to! Install prebuilts with `geode sdk install-prebuilts`, "
|
|
|
|
"or build Geode from source and add `set(GEODE_LINK_NIGHTLY On)` to your CMakeLists.txt."
|
2022-10-17 08:46:36 -04:00
|
|
|
)
|
2022-07-30 12:24:03 -04:00
|
|
|
endif()
|