diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b2647abb..f892b5a47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,8 @@ option(ENABLE_DSP_EMU "Enable DSP 56k emulator for Falcon mode" ON) option(ENABLE_TRACING "Enable tracing messages for debugging" ON) option(ENABLE_TOOLS "Build the Hatari tools" ON) +option(LIBRETRO_STATIC "Set STATIC mode for compiling libretro core" OFF) + if(ENABLE_LIBRETRO) set(LIBRETRO_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/src/retro/libretro-common/include" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f536ae58a..e57ce7b69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,8 +168,10 @@ endif() if(ENABLE_LIBRETRO) add_subdirectory(retro) - set_target_properties(Core PROPERTIES POSITION_INDEPENDENT_CODE TRUE) - set_target_properties(CoreHmsa PROPERTIES POSITION_INDEPENDENT_CODE TRUE) + if(NOT LIBRETRO_STATIC) + set_target_properties(Core PROPERTIES POSITION_INDEPENDENT_CODE TRUE) + set_target_properties(CoreHmsa PROPERTIES POSITION_INDEPENDENT_CODE TRUE) + endif(NOT LIBRETRO_STATIC) endif(ENABLE_LIBRETRO) if(ENABLE_HATARI) @@ -320,7 +322,13 @@ else() endif() if(ENABLE_LIBRETRO) - add_library(retro-hatari MODULE + if(LIBRETRO_STATIC) + set(LIBRETRO_TYPE STATIC) + else() + set(LIBRETRO_TYPE MODULE) + endif() + + add_library(retro-hatari ${LIBRETRO_TYPE} $ $ $ diff --git a/src/cpu/CMakeLists.txt b/src/cpu/CMakeLists.txt index 61333c071..60b0f276d 100644 --- a/src/cpu/CMakeLists.txt +++ b/src/cpu/CMakeLists.txt @@ -99,6 +99,6 @@ endif() add_library(UaeCpu OBJECT ${CPUEMU_SRCS} ${WINUAE_SRCS} custom.c events.c memory.c hatari-glue.c) -if(ENABLE_LIBRETRO) +if(ENABLE_LIBRETRO AND NOT LIBRETRO_STATIC) set_target_properties(UaeCpu PROPERTIES POSITION_INDEPENDENT_CODE TRUE) -endif(ENABLE_LIBRETRO) +endif(ENABLE_LIBRETRO AND NOT LIBRETRO_STATIC) diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 89710d5e1..a4a18d94e 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -28,7 +28,7 @@ add_library(DebugUT OBJECT symbols.c vars.c) -if(ENABLE_LIBRETRO) +if(ENABLE_LIBRETRO AND NOT LIBRETRO_STATIC) set_target_properties(Debug PROPERTIES POSITION_INDEPENDENT_CODE TRUE) set_target_properties(DebugUT PROPERTIES POSITION_INDEPENDENT_CODE TRUE) -endif(ENABLE_LIBRETRO) +endif(ENABLE_LIBRETRO AND NOT LIBRETRO_STATIC) diff --git a/src/falcon/CMakeLists.txt b/src/falcon/CMakeLists.txt index a83ee55e9..e633d8dad 100644 --- a/src/falcon/CMakeLists.txt +++ b/src/falcon/CMakeLists.txt @@ -5,6 +5,6 @@ endif(ENABLE_DSP_EMU) add_library(Falcon OBJECT crossbar.c nvram.c videl.c dsp.c ${DSP_SOURCES}) -if(ENABLE_LIBRETRO) +if(ENABLE_LIBRETRO AND NOT LIBRETRO_STATIC) set_target_properties(Falcon PROPERTIES POSITION_INDEPENDENT_CODE TRUE) -endif(ENABLE_LIBRETRO) +endif(ENABLE_LIBRETRO AND NOT LIBRETRO_STATIC) diff --git a/src/retro/CMakeLists.txt b/src/retro/CMakeLists.txt index 277c9c670..9df476804 100644 --- a/src/retro/CMakeLists.txt +++ b/src/retro/CMakeLists.txt @@ -18,4 +18,6 @@ add_library(UiRetro OBJECT vfs.c) target_include_directories(UiRetro PRIVATE ${LIBRETRO_INCLUDE_DIR}) -set_target_properties(UiRetro PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +if(NOT LIBRETRO_STATIC) + set_target_properties(UiRetro PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +endif(NOT LIBRETRO_STATIC)