aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'libpsn00b/CMakeLists.txt')
-rw-r--r--libpsn00b/CMakeLists.txt57
1 files changed, 27 insertions, 30 deletions
diff --git a/libpsn00b/CMakeLists.txt b/libpsn00b/CMakeLists.txt
index a662448..71cc659 100644
--- a/libpsn00b/CMakeLists.txt
+++ b/libpsn00b/CMakeLists.txt
@@ -13,11 +13,7 @@ project(
HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
)
-if(NOT DEFINED PSN00BSDK_LIBGCC)
- message(FATAL_ERROR "Failed to obtain information about the GCC toolchain. Check your toolchain settings.")
-elseif(PSN00BSDK_LIBGCC STREQUAL "PSN00BSDK_LIBGCC-NOTFOUND")
- message(FATAL_ERROR "Failed to find libgcc in the GCC toolchain's files. Check your toolchain settings, or set the path to libgcc using -DPSN00BSDK_LIBGCC.")
-endif()
+include(${PROJECT_SOURCE_DIR}/cmake/flags.cmake)
## Libraries
@@ -31,37 +27,36 @@ foreach(_library IN LISTS PSN00BSDK_LIBRARIES)
file(
GLOB_RECURSE _sources
- ${_path}/*.s
- ${_path}/*.c
- ${_path}/*.cpp
- ${_path}/*.cxx
+ ${_path}/*.s ${_path}/*.c ${_path}/*.cpp
)
- psn00bsdk_add_library(${_library} STATIC ${_sources})
-endforeach()
+ foreach(_suffix IN ITEMS _exe_nogprel _exe_gprel _dll)
+ set(_name ${_library}${_suffix})
+ list(APPEND _libraries ${_name})
-psn00bsdk_target_incbin(psxgpu PRIVATE _gpu_debug_font psxgpu/dbugfont.tim)
+ psn00bsdk_add_library(${_name} STATIC ${_sources})
+ target_link_libraries(${_name} PUBLIC psn00bsdk${_suffix})
+ endforeach()
+endforeach()
-# Extract libgcc's contents and merge them into libc after building.
-# Unfortunately glob expressions won't work on Windows, so we have to manually
-# enumerate the contents of libgcc and save the list to a temporary file (as it
-# is too long to be passed directly on the command line). This is actually the
-# most reliable way I found to do this (I tried $<TARGET_OBJECTS> to no avail).
-add_custom_command(
- TARGET c POST_BUILD
- COMMAND ${CMAKE_AR} t ${PSN00BSDK_LIBGCC} $<ANGLE-R>_libgcc.txt
- COMMAND ${CMAKE_AR} x ${PSN00BSDK_LIBGCC}
- COMMAND ${CMAKE_AR} q $<TARGET_FILE:c> \@_libgcc.txt
- COMMAND ${CMAKE_AR} s $<TARGET_FILE:c>
- #COMMAND ${CMAKE_AR} rsuU $<TARGET_FILE:c> *.o
- COMMENT "Merging libgcc contents into SDK libc"
-)
+# Add binary assets to each version of the libraries.
+foreach(_suffix IN ITEMS _exe_nogprel _exe_gprel _dll)
+ psn00bsdk_target_incbin(
+ psxgpu${_suffix} PRIVATE _gpu_debug_font
+ psxgpu/dbugfont.tim
+ )
+endforeach()
## Installation
install(
- TARGETS ${PSN00BSDK_LIBRARIES}
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpsn00b
+ TARGETS
+ psn00bsdk_common
+ psn00bsdk_exe_gprel
+ psn00bsdk_exe_nogprel
+ psn00bsdk_dll
+ ${_libraries}
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpsn00b/$<LOWER_CASE:$<CONFIG>>
EXPORT libpsn00b
)
install(
@@ -95,9 +90,11 @@ install(
)
# Generate an import script, which will be used by the setup script to find the
-# libraries.
+# libraries. Note that CMake actually generates two separate import scripts
+# (one setting configuration-specific options), so this won't create conflicts
+# once the debug and release builds are merged into the same installation tree.
install(
EXPORT libpsn00b
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpsn00b/cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpsn00b
#EXPORT_LINK_INTERFACE_LIBRARIES
)