From e89751dd72c87ba4e6eef27edbf42ae47a44a107 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 1 Jul 2023 16:04:24 -0500 Subject: [PATCH] Make libraries build as shared libraries on non-Apple/MS systems --- CMakeLists.txt | 11 +++++++++-- Makefile | 8 ++++---- src/keel/test/CMakeLists.txt | 2 +- src/nostalgia/modules/CMakeLists.txt | 4 ++-- src/nostalgia/modules/core/src/studio/CMakeLists.txt | 2 +- src/nostalgia/modules/scene/src/CMakeLists.txt | 8 ++++++++ src/nostalgia/modules/scene/src/studio/CMakeLists.txt | 2 +- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2993d084..bfcd1bc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,10 @@ else() set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + if(APPLE) set(CMAKE_MACOSX_RPATH OFF) set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Library/nostalgia") @@ -33,11 +37,14 @@ if(APPLE) set(NOSTALGIA_DIST_RESOURCES nostalgia-studio.app/Contents/Resources) set(NOSTALGIA_DIST_MAC_APP_CONTENTS nostalgia-studio.app/Contents) else() - set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib/ox" "$ORIGIN/../lib/nostalgia" "$ORIGIN/../") + if(UNIX) + set(BUILD_SHARED_LIBS ON) + endif() + set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(NOSTALGIA_DIST_BIN bin) set(NOSTALGIA_DIST_LIB lib) - set(NOSTALGIA_DIST_MODULE lib/nostalgia/modules) + set(NOSTALGIA_DIST_MODULE lib) set(NOSTALGIA_DIST_RESOURCES share) endif() diff --git a/Makefile b/Makefile index ea93c4e7..12642499 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ BUILDCORE_PATH=deps/buildcore include ${BUILDCORE_PATH}/base.mk ifeq ($(OS),darwin) - NOSTALGIA_STUDIO=./build/${HOST}/${CURRENT_BUILD}/src/nostalgia/studio/nostalgia-studio.app/Contents/MacOS/nostalgia-studio + NOSTALGIA_STUDIO=./build/${CURRENT_BUILD}/src/nostalgia/studio/nostalgia-studio.app/Contents/MacOS/nostalgia-studio MGBA=/Applications/mGBA.app/Contents/MacOS/mGBA else - NOSTALGIA_STUDIO=./build/${HOST}/${CURRENT_BUILD}/src/nostalgia/studio/nostalgia-studio + NOSTALGIA_STUDIO=./build/${CURRENT_BUILD}/bin/nostalgia-studio MGBA=mgba-qt endif @@ -16,7 +16,7 @@ pkg-gba: install .PHONY: run run: build - ./build/${HOST}/${CURRENT_BUILD}/src/nostalgia/player/nostalgia sample_project + ./build/${CURRENT_BUILD}/bin/nostalgia sample_project .PHONY: run-studio run-studio: build ${NOSTALGIA_STUDIO} @@ -25,7 +25,7 @@ gba-run: pkg-gba ${MGBA} nostalgia.gba .PHONY: debug debug: build - ${DEBUGGER} ./build/${HOST}/${CURRENT_BUILD}/src/nostalgia/player/nostalgia sample_project + ${DEBUGGER} ./build/${CURRENT_BUILD}/bin/nostalgia sample_project .PHONY: debug-studio debug-studio: build ${DEBUGGER} ${NOSTALGIA_STUDIO} diff --git a/src/keel/test/CMakeLists.txt b/src/keel/test/CMakeLists.txt index 54652a1a..ee256e29 100644 --- a/src/keel/test/CMakeLists.txt +++ b/src/keel/test/CMakeLists.txt @@ -8,4 +8,4 @@ target_link_libraries( Keel ) -add_test("[keel] KeelTest writeUuidHeader" KeelTest writeUuidHeader) +add_test("[keel] writeUuidHeader" ${CMAKE_BINARY_DIR}/bin/KeelTest writeUuidHeader) diff --git a/src/nostalgia/modules/CMakeLists.txt b/src/nostalgia/modules/CMakeLists.txt index 10ffadb4..0e7ae642 100644 --- a/src/nostalgia/modules/CMakeLists.txt +++ b/src/nostalgia/modules/CMakeLists.txt @@ -8,7 +8,7 @@ add_subdirectory(scene) # Keel add_library( - NostalgiaKeelModules OBJECT + NostalgiaKeelModules STATIC keelmodules.cpp ) target_link_libraries( @@ -27,7 +27,7 @@ install( # Studio if(TURBINE_BUILD_TYPE STREQUAL "Native") add_library( - NostalgiaStudioModules + NostalgiaStudioModules STATIC studiomodules.cpp ) target_link_libraries( diff --git a/src/nostalgia/modules/core/src/studio/CMakeLists.txt b/src/nostalgia/modules/core/src/studio/CMakeLists.txt index 988069cd..f73c7eda 100644 --- a/src/nostalgia/modules/core/src/studio/CMakeLists.txt +++ b/src/nostalgia/modules/core/src/studio/CMakeLists.txt @@ -8,7 +8,7 @@ add_library( ) add_library( - NostalgiaCore-Studio-ImGui OBJECT + NostalgiaCore-Studio-ImGui studiomodule.cpp paletteeditor-imgui.cpp tilesheeteditor-imgui.cpp diff --git a/src/nostalgia/modules/scene/src/CMakeLists.txt b/src/nostalgia/modules/scene/src/CMakeLists.txt index a5e0a1d6..9f3197ef 100644 --- a/src/nostalgia/modules/scene/src/CMakeLists.txt +++ b/src/nostalgia/modules/scene/src/CMakeLists.txt @@ -19,3 +19,11 @@ add_subdirectory(keel) if(NOSTALGIA_BUILD_STUDIO) add_subdirectory(studio) endif() + +install( + TARGETS + NostalgiaScene + DESTINATION + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/src/nostalgia/modules/scene/src/studio/CMakeLists.txt b/src/nostalgia/modules/scene/src/studio/CMakeLists.txt index 4c45aa2a..97a57703 100644 --- a/src/nostalgia/modules/scene/src/studio/CMakeLists.txt +++ b/src/nostalgia/modules/scene/src/studio/CMakeLists.txt @@ -1,5 +1,5 @@ add_library( - NostalgiaScene-Studio OBJECT + NostalgiaScene-Studio studiomodule.cpp sceneeditor-imgui.cpp sceneeditor.cpp