Skip to content

Commit

Permalink
cleaned up the output paths, and output filenames to more closely mat…
Browse files Browse the repository at this point in the history
…ch scons
  • Loading branch information
enetheru committed Oct 24, 2024
1 parent f268769 commit 1f685dc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 45 deletions.
30 changes: 14 additions & 16 deletions cmake/godotcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,28 @@ function( godotcpp_generate )

include(${PROJECT_SOURCE_DIR}/cmake/common_compiler_flags.cmake)

### Create the correct name (godot.os.build_type.system_bits)
set( SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>" )
set( BUILD_TYPE "$<LOWER_CASE:$<CONFIG>>" )
### Create the correct name (name.os.build_type.arch)
set( ARCH_KEYS "w64;x86_64;amd64" )
set( ARCH_VALUES "x86_64;x86_64;x86_64" )
set( SYSTEM_ARCH "$<LOWER_CASE:${CMAKE_SYSTEM_PROCESSOR}>")
set( ARCH_INDEX "$<LIST:FIND,${ARCH_KEYS},${SYSTEM_ARCH}>")
set( SYSTEM_ARCH "$<LIST:GET,${ARCH_VALUES},${ARCH_INDEX}>")

if(ANDROID)
# Added the android abi after system name
set(SYSTEM_NAME ${SYSTEM_NAME}.${ANDROID_ABI})

# Android does not have the bits at the end if you look at the main godot repo build
set(OUTPUT_NAME "godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}")
else()
set(OUTPUT_NAME "godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}.${BITS}")
endif()
set( BUILD_TYPE "$<LOWER_CASE:$<CONFIG>>" )
set( BUILD_TYPE $<IF:$<CONFIG:Debug>,template_debug,template_release> )

set( SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>$<$<BOOL:${ANDROID}>:.${ANDROID_ABI}>")

set_target_properties(${PROJECT_NAME}
set_target_properties( ${PROJECT_NAME}
PROPERTIES
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
CXX_VISIBILITY_PRESET ${GODOT_SYMBOL_VISIBILITY}
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
OUTPUT_NAME "${OUTPUT_NAME}"
ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_SOURCE_DIR}/bin>"
PDB_OUTPUT_DIRECTORY "$<1:${CMAKE_SOURCE_DIR}/bin>"
PREFIX lib
OUTPUT_NAME "${PROJECT_NAME}.${SYSTEM_NAME}.${BUILD_TYPE}.${SYSTEM_ARCH}"
)

endfunction()
56 changes: 27 additions & 29 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
cmake_minimum_required(VERSION 3.13)
project(godot-cpp-test LANGUAGES CXX)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(TARGET_PATH x11)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(TARGET_PATH win64)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_PATH macos)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(TARGET_PATH android)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(TARGET_PATH wasm32)
else()
message(FATAL_ERROR "Not implemented support for ${CMAKE_SYSTEM_NAME}")
endif()

set( IS_CLANG "$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:Clang>>" )
set( IS_GNU "$<CXX_COMPILER_ID:GNU>" )
set( IS_MSVC "$<CXX_COMPILER_ID:MSVC>" )

add_library( godot-cpp-test SHARED EXCLUDE_FROM_ALL )

# Define our godot-cpp-test library
add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL )

target_sources(${PROJECT_NAME}
target_sources( godot-cpp-test
PRIVATE
src/example.cpp
src/example.h
Expand All @@ -32,18 +13,18 @@ target_sources(${PROJECT_NAME}
src/tests.h
)

target_link_libraries(${PROJECT_NAME}
target_link_libraries( godot-cpp-test
PRIVATE
godot::cpp )
godot-cpp )

target_compile_options(${PROJECT_NAME}
target_compile_options( godot-cpp-test
PRIVATE
$<$<OR:${IS_CLANG},${IS_GNU}>:
-Wwrite-strings
>
)

target_link_options( ${PROJECT_NAME}
target_link_options( godot-cpp-test
PRIVATE
$<$<OR:${IS_CLANG},${IS_GNU}>:
-static-libgcc
Expand All @@ -56,11 +37,28 @@ target_link_options( ${PROJECT_NAME}
>
)

set_target_properties( ${PROJECT_NAME}
### Create the correct name (name.os.build_type.arch)
set( ARCH_KEYS "w64;x86_64;amd64" )
set( ARCH_VALUES "x86_64;x86_64;x86_64" )
set( SYSTEM_ARCH "$<LOWER_CASE:${CMAKE_SYSTEM_PROCESSOR}>")
set( ARCH_INDEX "$<LIST:FIND,${ARCH_KEYS},${SYSTEM_ARCH}>")
set( SYSTEM_ARCH "$<LIST:GET,${ARCH_VALUES},${ARCH_INDEX}>")


set( BUILD_TYPE "$<LOWER_CASE:$<CONFIG>>" )
set( BUILD_TYPE $<IF:$<CONFIG:Debug>,template_debug,template_release> )

set( SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>$<$<BOOL:${ANDROID}>:.${ANDROID_ABI}>")

set_target_properties( godot-cpp-test
PROPERTIES
OUTPUT_NAME "gdexample"
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
BUILD_RPATH_USE_ORIGIN ON
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${TARGET_PATH}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${TARGET_PATH}
CXX_VISIBILITY_PRESET ${GODOT_SYMBOL_VISIBILITY}
LIBRARY_OUTPUT_DIRECTORY "$<1:${CMAKE_CURRENT_SOURCE_DIR}/project/bin/>"
RUNTIME_OUTPUT_DIRECTORY "$<1:${CMAKE_CURRENT_SOURCE_DIR}/project/bin/>"
PDB_OUTPUT_DIRECTORY "$<1:${CMAKE_CURRENT_SOURCE_DIR}/project/bin/>"
PREFIX lib
OUTPUT_NAME "gdexample.${SYSTEM_NAME}.${BUILD_TYPE}.${SYSTEM_ARCH}"
)

0 comments on commit 1f685dc

Please sign in to comment.