Merge pull request #52 from audetto/cmake

Use cmake native find_package for OpenGL.
This commit is contained in:
Andrea 2021-12-31 16:30:21 +00:00 committed by GitHub
commit 89d9031752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 13 deletions

View file

@ -1,15 +1,16 @@
include(FindPkgConfig) include(FindPkgConfig)
include(FindZLIB)
pkg_check_modules(YAML REQUIRED yaml-0.1) find_package(ZLIB REQUIRED)
pkg_check_modules(MINIZIP REQUIRED minizip) pkg_search_module(YAML REQUIRED yaml-0.1)
pkg_check_modules(ZLIB REQUIRED zlib) pkg_search_module(MINIZIP REQUIRED minizip)
pkg_check_modules(SLIRP slirp) pkg_search_module(SLIRP slirp)
if ("${SLIRP_FOUND}" STREQUAL "") if ("${SLIRP_FOUND}" STREQUAL "")
message(WARNING "'libslirp' not found. Will use 'libpcap' instead") message(WARNING "'libslirp' not found. Will use 'libpcap' instead")
endif() endif()
pkg_check_modules(PCAP libpcap) pkg_search_module(PCAP libpcap)
if ("${PCAP_FOUND}" STREQUAL "") if ("${PCAP_FOUND}" STREQUAL "")
# old versions of pcap do not work with pkg-config # old versions of pcap do not work with pkg-config
# this is necessary on Rapsberri Pi OS # this is necessary on Rapsberri Pi OS
@ -214,7 +215,6 @@ target_include_directories(appleii PRIVATE
${PCAP_INCLUDE_DIRS} ${PCAP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
${SLIRP_INCLUDE_DIRS} ${SLIRP_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
Debugger Debugger
) )
@ -228,7 +228,7 @@ target_link_libraries(appleii PRIVATE
${MINIZIP_LIBRARIES} ${MINIZIP_LIBRARIES}
${PCAP_LIBRARIES} ${PCAP_LIBRARIES}
${SLIRP_LIBRARIES} ${SLIRP_LIBRARIES}
${ZLIB_LIBRARIES} ZLIB::ZLIB
) )
target_link_libraries(appleii PUBLIC target_link_libraries(appleii PUBLIC
@ -240,7 +240,6 @@ target_link_directories(appleii PRIVATE
${MINIZIP_LIBRARY_DIRS} ${MINIZIP_LIBRARY_DIRS}
${PCAP_LIBRARY_DIRS} ${PCAP_LIBRARY_DIRS}
${SLIRP_LIBRARY_DIRS} ${SLIRP_LIBRARY_DIRS}
${ZLIB_LIBRARY_DIRS}
) )
target_compile_options(appleii PUBLIC target_compile_options(appleii PUBLIC

View file

@ -1,4 +1,5 @@
include(FindPkgConfig) include(FindPkgConfig)
include(FindCurses)
set(SOURCE_FILES set(SOURCE_FILES
main.cpp main.cpp
@ -22,22 +23,23 @@ add_executable(applen
${HEADER_FILES} ${HEADER_FILES}
) )
pkg_search_module(NCURSESW REQUIRED ncursesw) find_package(Curses REQUIRED)
# pkg_search_module(NCURSESW REQUIRED ncursesw)
pkg_search_module(LIBEVDEV REQUIRED libevdev) pkg_search_module(LIBEVDEV REQUIRED libevdev)
target_include_directories(applen PRIVATE target_include_directories(applen PRIVATE
${NCURSESW_INCLUDE_DIRS} ${CURSES_INCLUDE_DIRS}
${LIBEVDEV_INCLUDE_DIRS} ${LIBEVDEV_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
) )
target_compile_options(applen PRIVATE target_compile_options(applen PRIVATE
${NCURSESW_CFLAGS_OTHER} ${CURSES_CFLAGS}
${LIBEVDEV_CFLAGS_OTHER} ${LIBEVDEV_CFLAGS_OTHER}
) )
target_link_libraries(applen PRIVATE target_link_libraries(applen PRIVATE
${NCURSESW_LIBRARIES} ${CURSES_LIBRARIES}
${LIBEVDEV_LIBRARIES} ${LIBEVDEV_LIBRARIES}
appleii appleii
common2 common2

View file

@ -1,4 +1,5 @@
include(FindPkgConfig) include(FindPkgConfig)
include(FindOpenGL)
add_executable(sa2) add_executable(sa2)
@ -6,6 +7,7 @@ set(IMGUI_PATH "imgui/imgui")
set(IMGUI_CLUB_PATH "imgui/imgui_club") set(IMGUI_CLUB_PATH "imgui/imgui_club")
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
# we should use find_package, but Ubuntu does not provide it for SDL2_image
pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image) pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image)
@ -17,7 +19,7 @@ else()
endif() endif()
if (SA2_OPENGL) if (SA2_OPENGL)
pkg_search_module(GLES2 REQUIRED opengl) find_package(OpenGL REQUIRED)
else() else()
pkg_search_module(GLES2 REQUIRED glesv2) pkg_search_module(GLES2 REQUIRED glesv2)
target_compile_definitions(sa2 PRIVATE target_compile_definitions(sa2 PRIVATE
@ -51,12 +53,14 @@ target_compile_features(sa2 PUBLIC cxx_std_17)
target_include_directories(sa2 PRIVATE target_include_directories(sa2 PRIVATE
${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}
${SDL2_IMAGE_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS}
${GLES2_INCLUDE_DIRS}
) )
target_link_libraries(sa2 PRIVATE target_link_libraries(sa2 PRIVATE
${SDL2_LIBRARIES} ${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES} ${SDL2_IMAGE_LIBRARIES}
${GLES2_LIBRARIES} ${GLES2_LIBRARIES}
OpenGL::GL
appleii appleii
common2 common2
windows windows