Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake: add ability to select frontends #48

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 34 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ cmake_minimum_required(VERSION 3.13)

project(applewin HOMEPAGE_URL "https://github.com/audetto/AppleWin")

option(BUILD_APPLEN "build ncurses frontend")
option(BUILD_QAPPLE "build Qt5 frontend")
option(BUILD_SA2 "build SDL2 frontend")
option(BUILD_LIBRETRO "build libretro core")

if (NOT (BUILD_APPLEN OR BUILD_QAPPLE OR BUILD_SA2 OR BUILD_LIBRETRO))
message(NOTICE "Building everything by default")
set(BUILD_APPLEN ON)
set(BUILD_QAPPLE ON)
set(BUILD_SA2 ON)
set(BUILD_LIBRETRO ON)
endif()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down Expand Up @@ -29,7 +42,7 @@ execute_process(COMMAND uname -n
if(${UNAME} STREQUAL raspberrypi)
# it is too slow and might cause out of memory issues
# more forensic is required
MESSAGE("Raspberry Pi detected: IPO disabled")
MESSAGE(NOTICE "Raspberry Pi detected: IPO disabled")
else()
include(CheckIPOSupported)
check_ipo_supported()
Expand All @@ -39,13 +52,28 @@ endif()
include_directories(source)

add_subdirectory(source)
add_subdirectory(source/frontends/common2)
add_subdirectory(source/frontends/ncurses)
add_subdirectory(source/frontends/qt)
add_subdirectory(source/frontends/sdl)
add_subdirectory(source/frontends/libretro)
add_subdirectory(test/TestCPU6502)

if (BUILD_LIBRETRO OR BUILD_APPLEN OR BUILD_SA2)
add_subdirectory(source/frontends/common2)
endif()

if (BUILD_APPLEN)
add_subdirectory(source/frontends/ncurses)
endif()

if (BUILD_QAPPLE)
add_subdirectory(source/frontends/qt)
endif()

if (BUILD_SA2)
add_subdirectory(source/frontends/sdl)
endif()

if (BUILD_LIBRETRO)
add_subdirectory(source/frontends/libretro)
endif()

set(CPACK_PACKAGE_VERSION "1.30.6.0")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Apple ][ emulator for Linux")
set(CPACK_PACKAGE_CONTACT "audetto <mariofutire@gmail.com>")
Expand Down
15 changes: 12 additions & 3 deletions linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ Video works, but the vertical flip is done in software.

Audio (speaker) works.

Must be manually configured:
``cmake -DLIBRETRO_COMMON_PATH=/path/to/libretro-common``

Easiest way to run from the ``build`` folder:
``retroarch -L source/frontends/libretro/applewin_libretro.so ../bin/MASTER.DSK``

Expand All @@ -120,6 +117,18 @@ cmake -DCMAKE_BUILD_TYPE=RELEASE ..
make
```

### Frontend selection

There are 4 `cmake` variables to selectively enable frontends: `BUILD_APPLEN`, `BUILD_QAPPLE`, `BUILD_SA2` and `BUILD_LIBRETRO`.

Usage:

```
cmake -DBUILD_SA2=ON -DBUILD_LIBRETRO=ON ..
```

or use `cmake-gui` (if none is selected, they are all built).

### Fedora

On Fedora 35, from a fresh installation, install all packages from [fedora.list.txt](source/linux/fedora.list.txt).
Expand Down
94 changes: 42 additions & 52 deletions source/frontends/libretro/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,52 +1,42 @@
# there is no simple package for libretro-common
# this requires user input
set(LIBRETRO_COMMON_PATH NONE CACHE PATH "path to libretro-common")

if (EXISTS ${LIBRETRO_COMMON_PATH}/include/libretro.h)
message("Using LIBRETRO_COMMON_PATH=${LIBRETRO_COMMON_PATH}")

set(SOURCE_FILES
environment.cpp
libretro.cpp
rdirectsound.cpp
game.cpp
joypadbase.cpp
joypad.cpp
analog.cpp
rdirectsound.cpp
retroregistry.cpp
retroframe.cpp
)

set(HEADER_FILES
environment.h
rdirectsound.h
game.h
joypadbase.h
joypad.h
analog.h
rdirectsound.h
retroregistry.h
retroframe.h
)

add_library(applewin_libretro SHARED
${SOURCE_FILES}
${HEADER_FILES}
)

target_include_directories(applewin_libretro PRIVATE
${LIBRETRO_COMMON_PATH}/include
)

target_link_libraries(applewin_libretro PRIVATE
appleii
common2
)

# just call it "applewin_libretro.so" as per libretro standard
set_target_properties(applewin_libretro PROPERTIES PREFIX "")

else()
message(WARNING "Bad LIBRETRO_COMMON_PATH=${LIBRETRO_COMMON_PATH}, skipping 'libretro' core")
endif()
set(SOURCE_FILES
environment.cpp
libretro.cpp
rdirectsound.cpp
game.cpp
joypadbase.cpp
joypad.cpp
analog.cpp
rdirectsound.cpp
retroregistry.cpp
retroframe.cpp
)

set(HEADER_FILES
environment.h
rdirectsound.h
game.h
joypadbase.h
joypad.h
analog.h
rdirectsound.h
retroregistry.h
retroframe.h
libretro-common/include/libretro.h
)

add_library(applewin_libretro SHARED
${SOURCE_FILES}
${HEADER_FILES}
)

target_include_directories(applewin_libretro PRIVATE
libretro-common/include
)

target_link_libraries(applewin_libretro PRIVATE
appleii
common2
)

# just call it "applewin_libretro.so" as per libretro standard
set_target_properties(applewin_libretro PROPERTIES PREFIX "")