1 # ---------------------------------------------------------------------------
3 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
4 # ---------------------------------------------------------------------------
5 # SquirrelJME is under the Mozilla Public License Version 2.0.
6 # See license.mkd for licensing and copyright information.
7 # ---------------------------------------------------------------------------
9 # Which type of build is being used?
10 if(LIBRETRO_REALLY_STATIC)
11 set(libRetroIsStatic ON)
12 set(libRetroBuildType STATIC)
13 set(libRetroCore Core)
14 set(libRetroBaseObjects $<TARGET_OBJECTS:Base>)
15 set(libRetroCoreObjects $<TARGET_OBJECTS:Core>)
17 set(libRetroIsStatic OFF)
18 set(libRetroBuildType SHARED)
19 set(libRetroCore CorePIC)
20 set(libRetroBaseObjects $<TARGET_OBJECTS:BasePIC>)
21 set(libRetroCoreObjects $<TARGET_OBJECTS:CorePIC>)
24 # Include tests with the build as well?
25 if(SQUIRRELJME_IS_DEBUG AND SQUIRRELJME_ENABLE_TESTING)
26 if(LIBRETRO_REALLY_STATIC)
27 set(libRetroTestObjects $<TARGET_OBJECTS:BasicTestLib>)
29 set(libRetroTestObjects $<TARGET_OBJECTS:BasicTestLibPIC>)
32 set(libRetroTestObjects)
36 add_library(squirreljme_libretro ${libRetroBuildType}
37 ${libRetroBaseObjects}
38 ${libRetroCoreObjects}
39 ${libRetroTestObjects}
51 # Make this PIC if not static
52 if(NOT libRetroIsStatic)
53 set_property(TARGET squirreljme_libretro
54 PROPERTY POSITION_INDEPENDENT_CODE ON)
57 # The base SquirrelJME core needs to be built
58 add_dependencies(squirreljme_libretro
61 # Name must be specifically set for RetroArch for it to work properly
62 if(ANDROID OR (DEFINED ANDROID_PLATFORM AND ANDROID_PLATFORM))
63 squirreljme_target_binary_name(squirreljme_libretro
64 "squirreljme_libretro_android")
66 squirreljme_target_binary_name(squirreljme_libretro
67 "squirreljme_libretro${LIBRETRO_SUFFIX}")
70 # Library location must be placed in the build output for the RetroArch
71 # build system to pick up the library
72 # Note that RUNTIME_OUTPUT_DIRECTORY is needed for the Windows build to output
73 # directories since .DLL files are output there and not where shared libraries
74 # go??? No idea really.
75 squirreljme_target_binary_output(squirreljme_libretro
76 "${SQUIRRELJME_DYLIB_OUTPUT_DIR}")
78 # RetroArch does not use any prefixes like "lib" for the cores
79 set_target_properties(squirreljme_libretro PROPERTIES
82 # Include main headers
83 target_include_directories(squirreljme_libretro PUBLIC
84 "${CMAKE_SOURCE_DIR}/include")
86 # Exports for Windows, etc.
87 if(NOT libRetroIsStatic)
88 squirreljme_target_shared_library_exports(npapi)
91 # Allow running the binary, as long as it is not static and we are on the
93 find_program(retroArchExe "retroarch")
94 if(retroArchExe AND NOT libRetroIsStatic AND
96 NOT SQUIRRELJME_IS_CROSS_COMPILE)
97 # Add target to run accordingly
98 add_custom_target(LibRetroRun
99 COMMAND "${retroArchExe}"
100 "-L" "$<TARGET_FILE:squirreljme_libretro>"
102 "--appendconfig=${CMAKE_CURRENT_SOURCE_DIR}/test.config"
103 "--log-file=${CMAKE_BINARY_DIR}/libretro.log"
104 DEPENDS squirreljme_libretro
107 # Do not try running this
108 set_target_properties(LibRetroRun PROPERTIES
109 EXCLUDE_FROM_ALL TRUE
110 EXCLUDE_FROM_DEFAULT_BUILD TRUE)
114 if(SQUIRRELJME_ENABLE_PACKING)
115 cpack_add_component(LIBRETRO
116 DISPLAY_NAME "SquirrelJME LibRetro"
117 DESCRIPTION "SquirrelJME running on LibRetro.")
118 install(TARGETS squirreljme_libretro
120 set(CPACK_DEBIAN_LIBRETRO_PACKAGE_DEPENDS
121 "retroarch | libretro-frontend")
122 set(CPACK_DEBIAN_PACKAGE_SUGGESTS