cmake: install FindGint.cmake (previously in the fxSDK)

This commit is contained in:
Lephe 2021-01-27 08:57:23 +01:00
parent 0ed5ead0a0
commit 815d479ab7
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 62 additions and 0 deletions

View file

@ -123,11 +123,17 @@ endif()
set_target_properties("${NAME}" PROPERTIES OUTPUT_NAME "${NAME}")
# Library file
install(TARGETS "${NAME}" DESTINATION "${FXSDK_COMPILER_INSTALL}")
# Linker script
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_SCRIPT}"
DESTINATION "${FXSDK_COMPILER_INSTALL}")
# Headers
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
DESTINATION "${FXSDK_COMPILER_INSTALL}"
FILES_MATCHING PATTERN "*.h")
# Auto-generated config header
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/gint/config.h"
DESTINATION "${FXSDK_COMPILER_INSTALL}/include/gint")
# CMake module to find gint
install(FILES cmake/FindGint.cmake DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")

56
cmake/FindGint.cmake Normal file
View file

@ -0,0 +1,56 @@
# Determine platform Code
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
set(PC cg)
set(INTF_DEFN FXCG50)
set(INTF_LINK "-T;fxcg50.ld")
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
set(PC fx)
set(INTF_DEFN FX9860G)
set(INTF_LINK "-T;fx9860g.ld")
else()
message(FATAL_ERROR "gint: unknown fxSDK platform '${FXSDK_PLATFORM}'")
endif()
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libgint-${PC}.a
OUTPUT_VARIABLE GINT_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=include/gint/config.h
OUTPUT_VARIABLE GINT_CONFIG_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if("${GINT_PATH}" STREQUAL "libgint-${PC}.a")
unset(PATH_TO_LIBGINT)
else()
set(PATH_TO_LIBGINT TRUE)
if(GINT_CONFIG_PATH)
execute_process(
COMMAND sed -E "s/#define.*GINT_VERSION\\s+\"(\\S+)\"$/\\1/p; d" ${GINT_CONFIG_PATH}
OUTPUT_VARIABLE GINT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Gint
REQUIRED_VARS PATH_TO_LIBGINT
VERSION_VAR GINT_VERSION
)
if(Gint_FOUND)
if(NOT TARGET Gint::Gint)
add_library(Gint::Gint UNKNOWN IMPORTED)
endif()
# No include directory or library path to specify, GCC handles that
set_target_properties(Gint::Gint PROPERTIES
IMPORTED_LOCATION "${GINT_PATH}"
INTERFACE_COMPILE_OPTIONS -fstrict-volatile-bitfields
INTERFACE_COMPILE_DEFINITIONS "${INTF_DEFN}"
INTERFACE_LINK_LIBRARIES -lgcc
INTERFACE_LINK_OPTIONS "${INTF_LINK}"
)
endif()