Skip to content

Commit

Permalink
cmake adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashifolfi committed Jun 29, 2024
1 parent b16f860 commit 0c08677
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 40 deletions.
43 changes: 3 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,11 @@
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)

# Create project
if (APPLE)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" FORCE)
endif()
project(godotrmlui
VERSION "0.1.0")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Include CMake libraries
include(CheckIPOSupported)

# Set up variables
set(GDRML_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if (APPLE)
set(GDRML_ARCH "universal")
endif()
set(GDRML_ADDON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/addons/${PROJECT_NAME}")
set(GDRML_BIN_DIR "${GDRML_ADDON_DIR}/bin")
set(GDRML_LIB_DIR "${CMAKE_SYSTEM_NAME}_${GDRML_ARCH}")

# Global CMake options
if(NOT PROJECT_IS_TOP_LEVEL)
message(FATAL_ERROR "${PROJECT_NAME} must be built standalone!")
endif()

# Print a message
message(STATUS "Building ${PROJECT_NAME} for ${GDRML_ARCH} on ${CMAKE_SYSTEM_NAME}")

# Set proper runpath
set(CMAKE_SKIP_BUILD_RPATH OFF)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
set(CMAKE_INSTALL_RPATH $ORIGIN)

# Compile with PIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
VERSION "0.1.0"
)

# Compile with LTO if supported
set(GDRML_USE_LTO OFF)
if(NOT (CMAKE_BUILD_TYPE MATCHES "Debug"))
check_ipo_supported(RESULT GODOTSOURCE_USE_LTO)
endif()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${GDRML_USE_LTO})
include(cmake/boilerplate.cmake)

# Hide everything by default
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
Expand Down
38 changes: 38 additions & 0 deletions cmake/boilerplate.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
if (APPLE)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" FORCE)
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Include CMake libraries
include(CheckIPOSupported)

# Set up variables
set(GDRML_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if (APPLE)
set(GDRML_ARCH "universal")
endif()

# Global CMake options
if(NOT PROJECT_IS_TOP_LEVEL)
message(FATAL_ERROR "${PROJECT_NAME} must be built standalone!")
endif()

# Print a message
message(STATUS "Building ${PROJECT_NAME} for ${GDRML_ARCH} on ${CMAKE_SYSTEM_NAME}")

# Set proper runpath
set(CMAKE_SKIP_BUILD_RPATH OFF)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
set(CMAKE_INSTALL_RPATH $ORIGIN)

# Compile with PIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Compile with LTO if supported
set(GDRML_USE_LTO OFF)
if(NOT (CMAKE_BUILD_TYPE MATCHES "Debug"))
check_ipo_supported(RESULT GDRML_USE_LTO)
endif()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${GDRML_USE_LTO})
4 changes: 4 additions & 0 deletions cmake/gdextension.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
set(GDRML_ADDON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/addons/${PROJECT_NAME}")
set(GDRML_BIN_DIR "${GDRML_ADDON_DIR}/bin")
set(GDRML_LIB_DIR "${CMAKE_SYSTEM_NAME}_${GDRML_ARCH}")

# Macro to set up many things at once for a given GDExtension
function(godot_configure_library TARGET)
# Define DEBUG macro
Expand Down

0 comments on commit 0c08677

Please sign in to comment.