cmake: refactor, better clang support
Do some reformatting towards the more modern cmake style. Clean up some code. Support linking to gcc compiled wxWidgets by setting `-D__GXX_ABI_VERSION=` appropriately for clang. Use the new method of calling `FindwxWidgets.cmake`, the old method causes some problems now. Set all necessary policies in both cmake files. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
7fb27c4df9
commit
b69fced749
|
@ -129,15 +129,15 @@ endif()
|
||||||
|
|
||||||
option(ENABLE_GBA_LOGGING "Enable extended GBA logging" ON)
|
option(ENABLE_GBA_LOGGING "Enable extended GBA logging" ON)
|
||||||
if(ENABLE_GBA_LOGGING)
|
if(ENABLE_GBA_LOGGING)
|
||||||
add_definitions(-DGBA_LOGGING )
|
add_definitions(-DGBA_LOGGING )
|
||||||
endif()
|
endif()
|
||||||
if(ENABLE_MMX)
|
if(ENABLE_MMX)
|
||||||
add_definitions(-DMMX)
|
add_definitions(-DMMX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The SDL port can't be built without debugging support
|
# The SDL port can't be built without debugging support
|
||||||
if(NOT ENABLE_DEBUGGER AND ENABLE_SDL)
|
if(NOT ENABLE_DEBUGGER AND ENABLE_SDL)
|
||||||
message(SEND_ERROR "The SDL port can't be built without debugging support")
|
message(SEND_ERROR "The SDL port can't be built without debugging support")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# this has to run after the toolchain is initialized so it can't be in
|
# this has to run after the toolchain is initialized so it can't be in
|
||||||
|
@ -224,7 +224,8 @@ if(ENABLE_LINK)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# set the standard libraries all ports use
|
# set the standard libraries all ports use
|
||||||
set(VBAMCORE_LIBS
|
set(
|
||||||
|
VBAMCORE_LIBS
|
||||||
vbamcore
|
vbamcore
|
||||||
fex
|
fex
|
||||||
${SDL2_LIBRARY}
|
${SDL2_LIBRARY}
|
||||||
|
@ -257,9 +258,9 @@ if(NOT ENABLE_FFMPEG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LIRC)
|
if(ENABLE_LIRC)
|
||||||
set(WITHLIRC 1)
|
set(WITHLIRC 1)
|
||||||
else()
|
else()
|
||||||
set(WITHLIRC 0)
|
set(WITHLIRC 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
@ -451,7 +452,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp)
|
set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -562,7 +562,8 @@ endif()
|
||||||
|
|
||||||
add_subdirectory (fex)
|
add_subdirectory (fex)
|
||||||
|
|
||||||
set(SRC_MAIN
|
set(
|
||||||
|
SRC_MAIN
|
||||||
src/Util.cpp
|
src/Util.cpp
|
||||||
src/common/ConfigManager.cpp
|
src/common/ConfigManager.cpp
|
||||||
src/common/dictionary.c
|
src/common/dictionary.c
|
||||||
|
@ -576,7 +577,8 @@ if(MSVC)
|
||||||
set(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
|
set(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HDR_MAIN
|
set(
|
||||||
|
HDR_MAIN
|
||||||
src/System.h
|
src/System.h
|
||||||
src/Util.h
|
src/Util.h
|
||||||
src/common/array.h
|
src/common/array.h
|
||||||
|
@ -602,7 +604,8 @@ if(ENABLE_NLS)
|
||||||
set(HDR_MAIN ${HDR_MAIN} src/NLS.h)
|
set(HDR_MAIN ${HDR_MAIN} src/NLS.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SRC_GBA
|
set(
|
||||||
|
SRC_GBA
|
||||||
src/gba/agbprint.cpp
|
src/gba/agbprint.cpp
|
||||||
src/gba/bios.cpp
|
src/gba/bios.cpp
|
||||||
src/gba/BreakpointStructures.cpp
|
src/gba/BreakpointStructures.cpp
|
||||||
|
@ -632,7 +635,8 @@ set(SRC_GBA
|
||||||
src/gba/Sram.cpp
|
src/gba/Sram.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HDR_GBA
|
set(
|
||||||
|
HDR_GBA
|
||||||
src/gba/agbprint.h
|
src/gba/agbprint.h
|
||||||
src/gba/bios.h
|
src/gba/bios.h
|
||||||
src/gba/BreakpointStructures.h
|
src/gba/BreakpointStructures.h
|
||||||
|
@ -655,7 +659,8 @@ set(HDR_GBA
|
||||||
src/gba/Sram.h
|
src/gba/Sram.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC_GB
|
set(
|
||||||
|
SRC_GB
|
||||||
src/gb/GB.cpp
|
src/gb/GB.cpp
|
||||||
src/gb/gbCheats.cpp
|
src/gb/gbCheats.cpp
|
||||||
src/gb/gbDis.cpp
|
src/gb/gbDis.cpp
|
||||||
|
@ -667,7 +672,8 @@ set(SRC_GB
|
||||||
src/gb/gbSound.cpp
|
src/gb/gbSound.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HDR_GB
|
set(
|
||||||
|
HDR_GB
|
||||||
src/gb/gb.h
|
src/gb/gb.h
|
||||||
src/gb/gbCheats.h
|
src/gb/gbCheats.h
|
||||||
src/gb/gbCodes.h
|
src/gb/gbCodes.h
|
||||||
|
@ -679,7 +685,8 @@ set(HDR_GB
|
||||||
src/gb/gbSound.h
|
src/gb/gbSound.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC_APU
|
set(
|
||||||
|
SRC_APU
|
||||||
src/apu/Blip_Buffer.cpp
|
src/apu/Blip_Buffer.cpp
|
||||||
src/apu/Effects_Buffer.cpp
|
src/apu/Effects_Buffer.cpp
|
||||||
src/apu/Gb_Apu.cpp
|
src/apu/Gb_Apu.cpp
|
||||||
|
@ -688,7 +695,8 @@ set(SRC_APU
|
||||||
src/apu/Multi_Buffer.cpp
|
src/apu/Multi_Buffer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HDR_APU
|
set(
|
||||||
|
HDR_APU
|
||||||
src/apu/blargg_common.h #Unused(?) but in the VS projects
|
src/apu/blargg_common.h #Unused(?) but in the VS projects
|
||||||
src/apu/blargg_config.h #Unused(?) but in the VS projects
|
src/apu/blargg_config.h #Unused(?) but in the VS projects
|
||||||
src/apu/blargg_source.h
|
src/apu/blargg_source.h
|
||||||
|
@ -699,7 +707,8 @@ set(HDR_APU
|
||||||
src/apu/Multi_Buffer.h
|
src/apu/Multi_Buffer.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC_SDL
|
set(
|
||||||
|
SRC_SDL
|
||||||
src/sdl/SDL.cpp
|
src/sdl/SDL.cpp
|
||||||
src/sdl/filters.cpp
|
src/sdl/filters.cpp
|
||||||
src/sdl/text.cpp
|
src/sdl/text.cpp
|
||||||
|
@ -709,7 +718,8 @@ set(SRC_SDL
|
||||||
src/sdl/expr-lex.cpp
|
src/sdl/expr-lex.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HDR_SDL
|
set(
|
||||||
|
HDR_SDL
|
||||||
src/sdl/filters.h
|
src/sdl/filters.h
|
||||||
src/sdl/text.h
|
src/sdl/text.h
|
||||||
src/sdl/inputSDL.h
|
src/sdl/inputSDL.h
|
||||||
|
@ -717,7 +727,8 @@ set(HDR_SDL
|
||||||
src/sdl/exprNode.h
|
src/sdl/exprNode.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC_FILTERS
|
set(
|
||||||
|
SRC_FILTERS
|
||||||
src/filters/2xSaI.cpp
|
src/filters/2xSaI.cpp
|
||||||
src/filters/admame.cpp
|
src/filters/admame.cpp
|
||||||
src/filters/bilinear.cpp
|
src/filters/bilinear.cpp
|
||||||
|
@ -730,7 +741,8 @@ set(SRC_FILTERS
|
||||||
src/filters/xBRZ/xbrz.cpp
|
src/filters/xBRZ/xbrz.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HDR_FILTERS
|
set(
|
||||||
|
HDR_FILTERS
|
||||||
src/filters/hq2x.h
|
src/filters/hq2x.h
|
||||||
src/filters/interp.h
|
src/filters/interp.h
|
||||||
src/filters/lq2x.h
|
src/filters/lq2x.h
|
||||||
|
@ -738,18 +750,21 @@ set(HDR_FILTERS
|
||||||
src/filters/xBRZ/xbrz.h
|
src/filters/xBRZ/xbrz.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC_HQ_C
|
set(
|
||||||
|
SRC_HQ_C
|
||||||
src/filters/hq/c/hq_implementation.cpp
|
src/filters/hq/c/hq_implementation.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HDR_HQ_C
|
set(
|
||||||
|
HDR_HQ_C
|
||||||
src/filters/hq/c/hq3x_pattern.h
|
src/filters/hq/c/hq3x_pattern.h
|
||||||
src/filters/hq/c/hq4x_pattern.h
|
src/filters/hq/c/hq4x_pattern.h
|
||||||
src/filters/hq/c/hq_base.h
|
src/filters/hq/c/hq_base.h
|
||||||
src/filters/hq/c/hq_shared.h
|
src/filters/hq/c/hq_shared.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC_HQ_ASM
|
set(
|
||||||
|
SRC_HQ_ASM
|
||||||
src/filters/hq/asm/hq3x_16.asm
|
src/filters/hq/asm/hq3x_16.asm
|
||||||
src/filters/hq/asm/hq3x_32.asm
|
src/filters/hq/asm/hq3x_32.asm
|
||||||
src/filters/hq/asm/hq4x_16.asm
|
src/filters/hq/asm/hq4x_16.asm
|
||||||
|
@ -769,12 +784,14 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_DEBUGGER)
|
if(ENABLE_DEBUGGER)
|
||||||
set(SRC_DEBUGGER
|
set(
|
||||||
|
SRC_DEBUGGER
|
||||||
src/gba/armdis.cpp
|
src/gba/armdis.cpp
|
||||||
src/gba/elf.cpp
|
src/gba/elf.cpp
|
||||||
src/gba/remote.cpp
|
src/gba/remote.cpp
|
||||||
)
|
)
|
||||||
set(HDR_DEBUGGER
|
set(
|
||||||
|
HDR_DEBUGGER
|
||||||
src/gba/armdis.h
|
src/gba/armdis.h
|
||||||
src/gba/elf.h
|
src/gba/elf.h
|
||||||
src/gba/remote.h
|
src/gba/remote.h
|
||||||
|
@ -841,13 +858,17 @@ if(ENABLE_SDL)
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
|
install(
|
||||||
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
|
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
|
||||||
RENAME vbam.cfg)
|
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
|
||||||
|
RENAME vbam.cfg
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
|
install(
|
||||||
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
|
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
|
||||||
RENAME vbam.cfg)
|
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
|
||||||
|
RENAME vbam.cfg
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -889,4 +910,5 @@ set(CPACK_PACKAGE_VERSION_MAJOR "2")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "0-Git-" ${COMMITHASH})
|
set(CPACK_PACKAGE_VERSION_PATCH "0-Git-" ${COMMITHASH})
|
||||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/dependencies")
|
list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/dependencies")
|
||||||
|
list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg")
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|
|
@ -30,32 +30,32 @@ option(ENABLE_FAUDIO "Enable FAudio sound output for the wxWidgets port" OFF)
|
||||||
|
|
||||||
option(ENABLE_OPENAL "Enable OpenAL for the wxWidgets port" OFF)
|
option(ENABLE_OPENAL "Enable OpenAL for the wxWidgets port" OFF)
|
||||||
|
|
||||||
IF(APPLE)
|
if(APPLE)
|
||||||
ADD_DEFINITIONS(-DwxMAC_USE_CORE_GRAPHICS)
|
add_definitions(-DwxMAC_USE_CORE_GRAPHICS)
|
||||||
ENDIF(APPLE)
|
endif()
|
||||||
|
|
||||||
if( NOT ENABLE_XAUDIO2 )
|
if(NOT ENABLE_XAUDIO2)
|
||||||
ADD_DEFINITIONS (-DNO_XAUDIO2)
|
add_definitions(-DNO_XAUDIO2)
|
||||||
endif( NOT ENABLE_XAUDIO2 )
|
endif()
|
||||||
|
|
||||||
if( NOT ENABLE_FAUDIO )
|
if(NOT ENABLE_FAUDIO)
|
||||||
ADD_DEFINITIONS (-DNO_FAUDIO)
|
add_definitions(-DNO_FAUDIO)
|
||||||
endif( NOT ENABLE_FAUDIO )
|
endif()
|
||||||
|
|
||||||
if(NOT ENABLE_DIRECT3D)
|
if(NOT ENABLE_DIRECT3D)
|
||||||
ADD_DEFINITIONS(-DNO_D3D)
|
add_definitions(-DNO_D3D)
|
||||||
endif(NOT ENABLE_DIRECT3D)
|
endif()
|
||||||
|
|
||||||
if(ENABLE_OPENAL)
|
if(ENABLE_OPENAL)
|
||||||
FIND_PACKAGE(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
|
include_directories(${OPENAL_INCLUDE_DIR})
|
||||||
|
|
||||||
IF(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe)))
|
if(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe)))
|
||||||
ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
|
add_definitions(-DAL_LIBTYPE_STATIC)
|
||||||
ENDIF()
|
endif()
|
||||||
else(ENABLE_OPENAL)
|
else(ENABLE_OPENAL)
|
||||||
ADD_DEFINITIONS (-DNO_OAL)
|
add_definitions(-DNO_OAL)
|
||||||
endif(ENABLE_OPENAL)
|
endif()
|
||||||
|
|
||||||
unset(FAUDIO_LIBS)
|
unset(FAUDIO_LIBS)
|
||||||
if(ENABLE_FAUDIO)
|
if(ENABLE_FAUDIO)
|
||||||
|
@ -117,9 +117,9 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
|
||||||
file(COPY ${_VCPKG_ROOT_DIR}/installed/${WINARCH}-windows/bin/SDL2.dll DESTINATION ${CMAKE_BINARY_DIR})
|
file(COPY ${_VCPKG_ROOT_DIR}/installed/${WINARCH}-windows/bin/SDL2.dll DESTINATION ${CMAKE_BINARY_DIR})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
SET(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm
|
set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# on e.g. msys2 add a couple of libraries wx needs
|
# on e.g. msys2 add a couple of libraries wx needs
|
||||||
#if(WIN32 AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang))
|
#if(WIN32 AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang))
|
||||||
|
@ -154,12 +154,7 @@ else()
|
||||||
set(wxWidgets_CONFIG_OPTIONS "--prefix=${CMAKE_PREFIX_PATH}")
|
set(wxWidgets_CONFIG_OPTIONS "--prefix=${CMAKE_PREFIX_PATH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
SET(wxWidgets_USE_UNICODE ON)
|
set(wxWidgets_USE_UNICODE ON)
|
||||||
# adv is for wxAboutBox
|
|
||||||
# xml, html is for xrc
|
|
||||||
# do not include gl at first
|
|
||||||
set(wxWidgets_USE_LIBS xrc xml html adv net core base)
|
|
||||||
#list(APPEND wxWidgets_CONFIG_OPTIONS --version=2.8)
|
|
||||||
|
|
||||||
# Check for gtk4 then gtk3 packages first, some dists like arch rename the
|
# Check for gtk4 then gtk3 packages first, some dists like arch rename the
|
||||||
# wx-config utility for these packages to e.g. wx-config-gtk3
|
# wx-config utility for these packages to e.g. wx-config-gtk3
|
||||||
|
@ -169,87 +164,67 @@ else()
|
||||||
find_program(wxWidgets_CONFIG_EXECUTABLE NAMES wx-config-gtk4 wx-config-gtk3 wx-config)
|
find_program(wxWidgets_CONFIG_EXECUTABLE NAMES wx-config-gtk4 wx-config-gtk3 wx-config)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# adv is for wxAboutBox
|
||||||
|
# xml, html is for xrc
|
||||||
# the gl lib may not be available, and if it looks like it is we still have to
|
# the gl lib may not be available, and if it looks like it is we still have to
|
||||||
# do a compile test later
|
# do a compile test later
|
||||||
list(APPEND wxWidgets_USE_LIBS gl)
|
find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl)
|
||||||
find_package(wxWidgets QUIET)
|
|
||||||
|
if(NOT wxWidgets_FOUND)
|
||||||
|
set(WX_HAS_OPENGL FALSE)
|
||||||
|
find_package(wxWidgets COMPONENTS xrc xml html adv net core base REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
cleanup_wx_vars()
|
cleanup_wx_vars()
|
||||||
normalize_wx_paths()
|
normalize_wx_paths()
|
||||||
|
|
||||||
SET(CHECK_WX_OPENGL FALSE)
|
include_directories(${wxWidgets_INCLUDE_DIRS})
|
||||||
|
|
||||||
IF(wxWidgets_FOUND)
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
SET(CHECK_WX_OPENGL TRUE)
|
|
||||||
ELSE()
|
|
||||||
SET(WX_HAS_OPENGL FALSE)
|
|
||||||
# the requirement check is later after the opengl compile test
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# tell wx to enable debug mode if possible, if the cmake module did not do it for us
|
# tell wx to enable debug mode if possible, if the cmake module did not do it for us
|
||||||
EXECUTE_PROCESS(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET)
|
execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET)
|
||||||
|
|
||||||
IF(WX_CONFIG_DEBUG EQUAL 0)
|
if(WX_CONFIG_DEBUG EQUAL 0)
|
||||||
ADD_DEFINITIONS(-DwxDEBUG_LEVEL=1)
|
add_definitions(-DwxDEBUG_LEVEL=1)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# this one should be safe in non-debug builds too
|
# this one should be safe in non-debug builds too
|
||||||
ADD_DEFINITIONS(-DWXDEBUG)
|
add_definitions(-DWXDEBUG)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
FOREACH(DEF ${wxWidgets_DEFINITIONS})
|
foreach(DEF ${wxWidgets_DEFINITIONS})
|
||||||
ADD_DEFINITIONS("-D${DEF}")
|
add_definitions("-D${DEF}")
|
||||||
ENDFOREACH()
|
endforeach()
|
||||||
|
|
||||||
# check if this build of wx actually has OpenGL support
|
foreach(CXX_COMPILE_FLAG ${wxWidgets_CXX_FLAGS})
|
||||||
|
add_compile_options(${CXX_COMPILE_FLAG})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${MY_CXX_FLAGS} ${MY_C_FLAGS} ${MY_CXX_LINKER_FLAGS} ${MY_C_LINKER_FLAGS} ${wxWidgets_LIBRARIES})
|
# set up variables for some compile/run checks for wxWidgets
|
||||||
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${wxWidgets_CXX_FLAGS} ${MY_CXX_FLAGS} ${MY_C_FLAGS})
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${MY_CXX_FLAGS} ${MY_C_FLAGS} ${MY_CXX_LINKER_FLAGS} ${MY_C_LINKER_FLAGS} ${wxWidgets_LIBRARIES})
|
||||||
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${wxWidgets_CXX_FLAGS} ${MY_CXX_FLAGS} ${MY_C_FLAGS})
|
||||||
|
|
||||||
IF(WIN32)
|
if(WIN32)
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-Wl,--subsystem,console")
|
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-Wl,--subsystem,console")
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--subsystem,console")
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--subsystem,console")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${wxWidgets_INCLUDE_DIRS})
|
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${wxWidgets_INCLUDE_DIRS})
|
||||||
|
|
||||||
FOREACH(DEF ${wxWidgets_DEFINITIONS})
|
foreach(DEF ${wxWidgets_DEFINITIONS})
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-D${DEF}")
|
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-D${DEF}")
|
||||||
ENDFOREACH()
|
endforeach()
|
||||||
|
|
||||||
# CheckCXXSourceCompiles ignores compiler flags, so we have to stuff them into the definitions
|
# CheckCXXSourceCompiles ignores compiler flags, so we have to stuff them into the definitions
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_FLAGS} ${CMAKE_REQUIRED_DEFINITIONS})
|
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_FLAGS} ${CMAKE_REQUIRED_DEFINITIONS})
|
||||||
|
|
||||||
INCLUDE(CheckCXXSourceCompiles)
|
# find the right C++ ABI version for wxWidgets, this is also necessary for the OpenGL check following
|
||||||
|
if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) AND NOT CMAKE_CROSSCOMPILING)
|
||||||
|
set(WX_ABI_FOUND_MATCH FALSE)
|
||||||
|
|
||||||
IF(CHECK_WX_OPENGL)
|
include(CheckCXXSourceRuns)
|
||||||
CHECK_CXX_SOURCE_COMPILES("
|
|
||||||
#include <wx/wxprec.h>
|
|
||||||
#include <wx/config.h>
|
|
||||||
#include <wx/glcanvas.h>
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
set(WX_TEST_CONSOLE_APP "
|
||||||
wxGLCanvas canvas(NULL, wxID_ANY, NULL, wxPoint(0, 0), wxSize(300, 300), 0);
|
|
||||||
return 0;
|
|
||||||
}" WX_HAS_OPENGL)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(NOT WX_HAS_OPENGL)
|
|
||||||
ADD_DEFINITIONS(-DNO_OGL)
|
|
||||||
LIST(REMOVE_ITEM wxWidgets_USE_LIBS gl)
|
|
||||||
find_package(wxWidgets REQUIRED)
|
|
||||||
normalize_wx_paths()
|
|
||||||
cleanup_wx_vars()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CROSSCOMPILING)
|
|
||||||
SET(WX_ABI_FOUND_MATCH FALSE)
|
|
||||||
|
|
||||||
INCLUDE(CheckCXXSourceRuns)
|
|
||||||
|
|
||||||
SET(WX_TEST_CONSOLE_APP "
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <wx/wxprec.h>
|
#include <wx/wxprec.h>
|
||||||
|
@ -319,130 +294,155 @@ int main(int argc, char** argv)
|
||||||
")
|
")
|
||||||
|
|
||||||
# on windows we need the trampoline library from dependencies
|
# on windows we need the trampoline library from dependencies
|
||||||
IF(WIN32)
|
if(WIN32)
|
||||||
# minhook requires -fpermissive unfortunately
|
# minhook requires -fpermissive unfortunately
|
||||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -fpermissive)
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -fpermissive)
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -fpermissive -w "-I${CMAKE_SOURCE_DIR}/dependencies/minhook/include")
|
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -fpermissive -w "-I${CMAKE_SOURCE_DIR}/dependencies/minhook/include")
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -Wl,--subsystem,console)
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -Wl,--subsystem,console)
|
||||||
|
|
||||||
IF(AMD64)
|
if(AMD64)
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook_64.a")
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook_64.a")
|
||||||
ELSE() # assume 32 bit windows
|
else() # assume 32 bit windows
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook.a")
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook.a")
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
CHECK_CXX_SOURCE_RUNS("${WX_TEST_CONSOLE_APP}" WX_DEFAULT_ABI_VERSION_COMPATIBLE)
|
check_cxx_source_runs("${WX_TEST_CONSOLE_APP}" WX_DEFAULT_ABI_VERSION_COMPATIBLE)
|
||||||
|
|
||||||
# remove -fpermissive set for minhook
|
# remove -fpermissive set for minhook
|
||||||
list(REMOVE_ITEM CMAKE_REQUIRED_FLAGS -fpermissive)
|
list(REMOVE_ITEM CMAKE_REQUIRED_FLAGS -fpermissive)
|
||||||
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -fpermissive)
|
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -fpermissive)
|
||||||
|
|
||||||
IF(NOT WX_DEFAULT_ABI_VERSION_COMPATIBLE)
|
if(NOT WX_DEFAULT_ABI_VERSION_COMPATIBLE)
|
||||||
# currently goes up to 11 with gcc7, but we give it some room
|
# currently goes up to 11 with gcc7, but we give it some room
|
||||||
SET(WX_ABI_VERSION 15)
|
set(WX_ABI_VERSION 15)
|
||||||
|
|
||||||
SET(CURRENT_DEFS ${CMAKE_REQUIRED_DEFINITIONS})
|
set(CURRENT_DEFS ${CMAKE_REQUIRED_DEFINITIONS})
|
||||||
SET(CURRENT_LIBS ${CMAKE_REQUIRED_LIBRARIES})
|
set(CURRENT_LIBS ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
|
|
||||||
WHILE(NOT WX_ABI_VERSION EQUAL -1)
|
while(NOT WX_ABI_VERSION EQUAL -1)
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS} "-fabi-version=${WX_ABI_VERSION}")
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS} "-fabi-version=${WX_ABI_VERSION}")
|
set(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS} "-fabi-version=${WX_ABI_VERSION}")
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS} "-fabi-version=${WX_ABI_VERSION}")
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS} "-D__GXX_ABI_VERSION=10${WX_ABI_VERSION}")
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS} "-D__GXX_ABI_VERSION=10${WX_ABI_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
SET(WX_ABI_VAR "WX_ABI_VERSION_${WX_ABI_VERSION}")
|
set(WX_ABI_VAR "WX_ABI_VERSION_${WX_ABI_VERSION}")
|
||||||
|
|
||||||
CHECK_CXX_SOURCE_RUNS("${WX_TEST_CONSOLE_APP}" ${WX_ABI_VAR})
|
check_cxx_source_runs("${WX_TEST_CONSOLE_APP}" ${WX_ABI_VAR})
|
||||||
|
|
||||||
IF(${${WX_ABI_VAR}})
|
if(${${WX_ABI_VAR}})
|
||||||
SET(WX_ABI_FOUND_MATCH TRUE)
|
set(WX_ABI_FOUND_MATCH TRUE)
|
||||||
BREAK()
|
break()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
MATH(EXPR WX_ABI_VERSION "${WX_ABI_VERSION} - 1")
|
math(EXPR WX_ABI_VERSION "${WX_ABI_VERSION} - 1")
|
||||||
ENDWHILE()
|
endwhile()
|
||||||
|
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS})
|
set(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS})
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS})
|
set(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(WX_ABI_FOUND_MATCH)
|
if(WX_ABI_FOUND_MATCH)
|
||||||
# add C++ flags
|
# add C++ flags
|
||||||
STRING(REGEX REPLACE "<FLAGS>" "<FLAGS> -fabi-version=${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -fabi-version=${WX_ABI_VERSION}")
|
string(REGEX REPLACE "<FLAGS>" "<FLAGS> -fabi-version=${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
|
||||||
ENDIF()
|
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -fabi-version=${WX_ABI_VERSION}")
|
||||||
ENDIF()
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
|
string(REGEX REPLACE "<FLAGS>" "<FLAGS> -D__GXX_ABI_VERSION=10${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
|
||||||
|
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -D__GXX_ABI_VERSION=10${WX_ABI_VERSION}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# now check for OpenGL
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
|
if(NOT DEFINED WX_HAS_OPENGL)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
#include <wx/glcanvas.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
wxGLCanvas canvas(NULL, wxID_ANY, NULL, wxPoint(0, 0), wxSize(300, 300), 0);
|
||||||
|
return 0;
|
||||||
|
}" WX_HAS_OPENGL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WX_HAS_OPENGL)
|
||||||
|
add_definitions(-DNO_OGL)
|
||||||
|
endif()
|
||||||
|
|
||||||
# end of wx compile checks
|
# end of wx compile checks
|
||||||
|
|
||||||
FOREACH(CXX_COMPILE_FLAG ${wxWidgets_CXX_FLAGS})
|
|
||||||
ADD_COMPILE_OPTIONS(${CXX_COMPILE_FLAG})
|
|
||||||
ENDFOREACH()
|
|
||||||
|
|
||||||
# we make some direct gtk/gdk calls on linux and such
|
# we make some direct gtk/gdk calls on linux and such
|
||||||
# so need to link the gtk that wx was built with
|
# so need to link the gtk that wx was built with
|
||||||
IF(NOT WIN32 AND NOT APPLE)
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
FIND_PACKAGE(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
FIND_PATH(WX_CONFIG_H NAMES wx/config.h PATHS ${wxWidgets_INCLUDE_DIRS})
|
find_path(WX_CONFIG_H NAMES wx/config.h PATHS ${wxWidgets_INCLUDE_DIRS})
|
||||||
IF(NOT WX_CONFIG_H)
|
if(NOT WX_CONFIG_H)
|
||||||
MESSAGE(FATAL_ERROR "Could not find wx/config.h in ${wxWidgets_INCLUDE_DIRS}")
|
message(FATAL_ERROR "Could not find wx/config.h in ${wxWidgets_INCLUDE_DIRS}")
|
||||||
ENDIF()
|
endif()
|
||||||
SET(WX_CONFIG_H "${WX_CONFIG_H}/wx/config.h")
|
set(WX_CONFIG_H "${WX_CONFIG_H}/wx/config.h")
|
||||||
|
|
||||||
INCLUDE(CheckCXXSymbolExists)
|
include(CheckCXXSymbolExists)
|
||||||
CHECK_CXX_SYMBOL_EXISTS(__WXGTK4__ ${WX_CONFIG_H} WX_USING_GTK4)
|
check_cxx_symbol_exists(__WXGTK4__ ${WX_CONFIG_H} WX_USING_GTK4)
|
||||||
CHECK_CXX_SYMBOL_EXISTS(__WXGTK3__ ${WX_CONFIG_H} WX_USING_GTK3)
|
check_cxx_symbol_exists(__WXGTK3__ ${WX_CONFIG_H} WX_USING_GTK3)
|
||||||
IF(WX_USING_GTK4)
|
if(WX_USING_GTK4)
|
||||||
PKG_CHECK_MODULES(GTK4 REQUIRED gtk+-4.0)
|
pkg_check_modules(GTK4 REQUIRED gtk+-4.0)
|
||||||
IF(NOT GTK4_INCLUDE_DIRS)
|
if(NOT GTK4_INCLUDE_DIRS)
|
||||||
MESSAGE(FATAL_ERROR "Could not find gtk4")
|
message(FATAL_ERROR "Could not find gtk4")
|
||||||
ENDIF()
|
endif()
|
||||||
INCLUDE_DIRECTORIES(${GTK4_INCLUDE_DIRS})
|
include_directories(${GTK4_INCLUDE_DIRS})
|
||||||
LINK_DIRECTORIES(${GTK4_LIBRARY_DIRS})
|
link_directories(${GTK4_LIBRARY_DIRS})
|
||||||
ADD_COMPILE_OPTIONS(${GTK4_CFLAGS_OTHER})
|
add_compile_options(${GTK4_CFLAGS_OTHER})
|
||||||
SET(GTK_LIBRARIES ${GTK4_LIBRARIES})
|
set(GTK_LIBRARIES ${GTK4_LIBRARIES})
|
||||||
ELSEIF(WX_USING_GTK3)
|
elseif(WX_USING_GTK3)
|
||||||
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
|
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||||
IF(NOT GTK3_INCLUDE_DIRS)
|
if(NOT GTK3_INCLUDE_DIRS)
|
||||||
MESSAGE(FATAL_ERROR "Could not find gtk3")
|
message(FATAL_ERROR "Could not find gtk3")
|
||||||
ENDIF()
|
endif()
|
||||||
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
|
include_directories(${GTK3_INCLUDE_DIRS})
|
||||||
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
|
link_directories(${GTK3_LIBRARY_DIRS})
|
||||||
ADD_COMPILE_OPTIONS(${GTK3_CFLAGS_OTHER})
|
add_compile_options(${GTK3_CFLAGS_OTHER})
|
||||||
SET(GTK_LIBRARIES ${GTK3_LIBRARIES})
|
set(GTK_LIBRARIES ${GTK3_LIBRARIES})
|
||||||
ELSE()
|
else()
|
||||||
CHECK_CXX_SYMBOL_EXISTS(__WXGTK20__ ${WX_CONFIG_H} WX_USING_GTK2)
|
check_cxx_symbol_exists(__WXGTK20__ ${WX_CONFIG_H} WX_USING_GTK2)
|
||||||
IF(WX_USING_GTK2)
|
if(WX_USING_GTK2)
|
||||||
# try to use pkg-config to find gtk2 first
|
# try to use pkg-config to find gtk2 first
|
||||||
PKG_CHECK_MODULES(GTK2 REQUIRED gtk+-2.0)
|
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
|
||||||
IF(GTK2_INCLUDE_DIRS)
|
if(GTK2_INCLUDE_DIRS)
|
||||||
INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
|
include_directories(${GTK2_INCLUDE_DIRS})
|
||||||
LINK_DIRECTORIES(${GTK2_LIBRARY_DIRS})
|
link_directories(${GTK2_LIBRARY_DIRS})
|
||||||
ADD_COMPILE_OPTIONS(${GTK2_CFLAGS_OTHER})
|
add_compile_options(${GTK2_CFLAGS_OTHER})
|
||||||
SET(GTK_LIBRARIES ${GTK2_LIBRARIES})
|
set(GTK_LIBRARIES ${GTK2_LIBRARIES})
|
||||||
ELSE()
|
else()
|
||||||
# and if that fails, use the cmake module
|
# and if that fails, use the cmake module
|
||||||
FIND_PACKAGE(GTK2 REQUIRED gtk)
|
find_package(GTK2 REQUIRED gtk)
|
||||||
IF(NOT GTK2_INCLUDE_DIRS)
|
if(NOT GTK2_INCLUDE_DIRS)
|
||||||
MESSAGE(FATAL_ERROR "Could not find gtk2")
|
message(FATAL_ERROR "Could not find gtk2")
|
||||||
ENDIF()
|
endif()
|
||||||
INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
|
include_directories(${GTK2_INCLUDE_DIRS})
|
||||||
ADD_COMPILE_OPTIONS(${GTK2_DEFINITIONS})
|
add_compile_options(${GTK2_DEFINITIONS})
|
||||||
SET(GTK_LIBRARIES ${GTK2_LIBRARIES})
|
set(GTK_LIBRARIES ${GTK2_LIBRARIES})
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
FIND_PACKAGE(GTK REQUIRED gtk)
|
find_package(GTK REQUIRED gtk)
|
||||||
IF(NOT GTK_INCLUDE_DIRS)
|
if(NOT GTK_INCLUDE_DIRS)
|
||||||
MESSAGE(FATAL_ERROR "Could not find gtk")
|
message(FATAL_ERROR "Could not find gtk")
|
||||||
ENDIF()
|
endif()
|
||||||
INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS})
|
include_directories(${GTK_INCLUDE_DIRS})
|
||||||
ADD_COMPILE_OPTIONS(${GTK_DEFINITIONS})
|
add_compile_options(${GTK_DEFINITIONS})
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
if (wxWidgets_USE_FILE)
|
if(wxWidgets_USE_FILE)
|
||||||
INCLUDE(${wxWidgets_USE_FILE})
|
include(${wxWidgets_USE_FILE})
|
||||||
endif()
|
endif()
|
||||||
endif() # wxWidgets checks
|
endif() # wxWidgets checks
|
||||||
|
|
||||||
|
@ -459,10 +459,6 @@ else()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32 AND ENABLE_DIRECTX)
|
|
||||||
find_packge(DirectX REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# contrib widgets
|
# contrib widgets
|
||||||
include_directories(widgets)
|
include_directories(widgets)
|
||||||
|
|
||||||
|
@ -470,7 +466,7 @@ include_directories(widgets)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
SET(XRC_SOURCES
|
set(XRC_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/AccelConfig.xrc
|
${CMAKE_CURRENT_SOURCE_DIR}/xrc/AccelConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatAdd.xrc
|
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatAdd.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatCreate.xrc
|
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatCreate.xrc
|
||||||
|
@ -510,16 +506,16 @@ SET(XRC_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/SoundConfig.xrc
|
${CMAKE_CURRENT_SOURCE_DIR}/xrc/SoundConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/TileViewer.xrc
|
${CMAKE_CURRENT_SOURCE_DIR}/xrc/TileViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/SpeedupConfig.xrc
|
${CMAKE_CURRENT_SOURCE_DIR}/xrc/SpeedupConfig.xrc
|
||||||
)
|
)
|
||||||
|
|
||||||
# wxrc does not support xrs files in -c output (> 10x compression)
|
# wxrc does not support xrs files in -c output (> 10x compression)
|
||||||
# we do it using the bin2c.c utility
|
# we do it using the bin2c.c utility
|
||||||
|
|
||||||
SET(BIN2C ${CMAKE_BINARY_DIR}/bin2c)
|
set(BIN2C ${CMAKE_BINARY_DIR}/bin2c)
|
||||||
|
|
||||||
INCLUDE(HostCompile)
|
include(HostCompile)
|
||||||
|
|
||||||
HOST_COMPILE(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C})
|
host_compile(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C})
|
||||||
|
|
||||||
if(WXRC)
|
if(WXRC)
|
||||||
separate_arguments(WXRC UNIX_COMMAND "${WXRC}")
|
separate_arguments(WXRC UNIX_COMMAND "${WXRC}")
|
||||||
|
@ -529,7 +525,6 @@ endif()
|
||||||
|
|
||||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL CYGWIN)
|
if(CMAKE_HOST_SYSTEM_NAME STREQUAL CYGWIN)
|
||||||
# pass xrc sources through cygpath in case we only have native wxrc
|
# pass xrc sources through cygpath in case we only have native wxrc
|
||||||
|
|
||||||
set(new_xrc_sources)
|
set(new_xrc_sources)
|
||||||
|
|
||||||
foreach(xrc ${XRC_SOURCES})
|
foreach(xrc ${XRC_SOURCES})
|
||||||
|
@ -540,126 +535,135 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL CYGWIN)
|
||||||
set(XRC_SOURCES ${new_xrc_sources})
|
set(XRC_SOURCES ${new_xrc_sources})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs
|
add_custom_command(
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
OUTPUT wxvbam.xrs
|
||||||
COMMAND ${WXRC} ${XRC_SOURCES} "--output=wxvbam.xrs"
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
DEPENDS ${XRC_SOURCES})
|
COMMAND ${WXRC} ${XRC_SOURCES} "--output=wxvbam.xrs"
|
||||||
|
DEPENDS ${XRC_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT builtin-xrc.h
|
add_custom_command(
|
||||||
COMMAND ${BIN2C} wxvbam.xrs builtin-xrc.h builtin_xrs
|
OUTPUT builtin-xrc.h
|
||||||
DEPENDS wxvbam.xrs)
|
COMMAND ${BIN2C} wxvbam.xrs builtin-xrc.h builtin_xrs
|
||||||
|
DEPENDS wxvbam.xrs
|
||||||
|
)
|
||||||
|
|
||||||
# use a built-in vba-over.ini if no config file present
|
# use a built-in vba-over.ini if no config file present
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT builtin-over.h
|
add_custom_command(
|
||||||
COMMAND ${BIN2C} ${CMAKE_CURRENT_SOURCE_DIR}/../vba-over.ini builtin-over.h builtin_over
|
OUTPUT builtin-over.h
|
||||||
DEPENDS ../vba-over.ini)
|
COMMAND ${BIN2C} ${CMAKE_CURRENT_SOURCE_DIR}/../vba-over.ini builtin-over.h builtin_over
|
||||||
|
DEPENDS ../vba-over.ini
|
||||||
|
)
|
||||||
|
|
||||||
# I don't like duplicating/triplicating code, so I only declare
|
# I don't like duplicating/triplicating code, so I only declare
|
||||||
# event handlers once, and copy them in other places they are needed
|
# event handlers once, and copy them in other places they are needed
|
||||||
# all using portable cmake code
|
# all using portable cmake code
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT cmdtab.cpp cmdhandlers.h cmd-evtable.h
|
add_custom_command(
|
||||||
COMMAND
|
OUTPUT cmdtab.cpp cmdhandlers.h cmd-evtable.h
|
||||||
${CMAKE_COMMAND} -D OUTDIR=${CMAKE_CURRENT_BINARY_DIR} -P copy-events.cmake
|
COMMAND ${CMAKE_COMMAND} -D OUTDIR=${CMAKE_CURRENT_BINARY_DIR} -P copy-events.cmake
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DEPENDS cmdevents.cpp)
|
DEPENDS cmdevents.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# the following should be in the main file for consistency with
|
# the following should be in the main file for consistency with
|
||||||
# other front ends, but can't due to cmake issues
|
# other front ends, but can't due to cmake issues
|
||||||
# then again, the main file should be split up into separate dirs anyway
|
# then again, the main file should be split up into separate dirs anyway
|
||||||
#
|
|
||||||
|
|
||||||
SET( SRC_WX
|
set(
|
||||||
wxvbam.cpp
|
SRC_WX
|
||||||
guiinit.cpp
|
wxvbam.cpp
|
||||||
viewers.cpp
|
guiinit.cpp
|
||||||
gfxviewers.cpp
|
viewers.cpp
|
||||||
cmdevents.cpp
|
gfxviewers.cpp
|
||||||
opts.cpp
|
cmdevents.cpp
|
||||||
sys.cpp
|
opts.cpp
|
||||||
panel.cpp
|
sys.cpp
|
||||||
viewsupt.cpp
|
panel.cpp
|
||||||
wayland.cpp
|
viewsupt.cpp
|
||||||
strutils.cpp
|
wayland.cpp
|
||||||
widgets/keyedit.cpp
|
strutils.cpp
|
||||||
widgets/joyedit.cpp
|
widgets/keyedit.cpp
|
||||||
widgets/sdljoy.cpp
|
widgets/joyedit.cpp
|
||||||
widgets/wxmisc.cpp
|
widgets/sdljoy.cpp
|
||||||
# probably ought to be in common
|
widgets/wxmisc.cpp
|
||||||
../sdl/text.cpp
|
# probably ought to be in common
|
||||||
# from external source with minor modifications
|
../sdl/text.cpp
|
||||||
widgets/checkedlistctrl.cpp
|
# from external source with minor modifications
|
||||||
# generated
|
widgets/checkedlistctrl.cpp
|
||||||
cmdtab.cpp
|
# generated
|
||||||
# generated includes must be explicitly listed
|
cmdtab.cpp
|
||||||
builtin-xrc.h
|
# generated includes must be explicitly listed
|
||||||
builtin-over.h
|
builtin-xrc.h
|
||||||
cmdhandlers.h
|
builtin-over.h
|
||||||
cmd-evtable.h
|
cmdhandlers.h
|
||||||
#Icon File
|
cmd-evtable.h
|
||||||
xrc/vbam.xpm
|
# icon File
|
||||||
|
xrc/vbam.xpm
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(APPLE)
|
if(APPLE)
|
||||||
SET(SRC_WX ${SRC_WX} macsupport.mm)
|
set(SRC_WX ${SRC_WX} macsupport.mm)
|
||||||
ENDIF(APPLE)
|
endif()
|
||||||
|
|
||||||
SET( HDR_WX
|
set(
|
||||||
wxvbam.h
|
HDR_WX
|
||||||
drawing.h
|
wxvbam.h
|
||||||
filters.h
|
drawing.h
|
||||||
ioregs.h
|
filters.h
|
||||||
opts.h
|
ioregs.h
|
||||||
viewsupt.h
|
opts.h
|
||||||
wxhead.h
|
viewsupt.h
|
||||||
wayland.h
|
wxhead.h
|
||||||
widgets/wx/keyedit.h
|
wayland.h
|
||||||
widgets/wx/joyedit.h
|
widgets/wx/keyedit.h
|
||||||
widgets/wx/sdljoy.h
|
widgets/wx/joyedit.h
|
||||||
widgets/wx/webupdatedef.h
|
widgets/wx/sdljoy.h
|
||||||
widgets/wx/wxmisc.h
|
widgets/wx/webupdatedef.h
|
||||||
# probably ought to be in common
|
widgets/wx/wxmisc.h
|
||||||
../sdl/text.h
|
# probably ought to be in common
|
||||||
# from external source with minor modifications
|
../sdl/text.h
|
||||||
widgets/wx/checkedlistctrl.h
|
# from external source with minor modifications
|
||||||
|
widgets/wx/checkedlistctrl.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( RES_WX
|
set(
|
||||||
|
RES_WX
|
||||||
${XRC_SOURCES}
|
${XRC_SOURCES}
|
||||||
../vba-over.ini
|
../vba-over.ini
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( CM_STUFF
|
set(
|
||||||
|
CM_STUFF
|
||||||
copy-events.cmake
|
copy-events.cmake
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(ENABLE_OPENAL)
|
if(ENABLE_OPENAL)
|
||||||
SET( SRC_WX ${SRC_WX} openal.cpp )
|
set(SRC_WX ${SRC_WX} openal.cpp)
|
||||||
SET( HDR_WX ${HDR_WX} openal.h )
|
set(HDR_WX ${HDR_WX} openal.h)
|
||||||
ENDIF(ENABLE_OPENAL)
|
endif()
|
||||||
|
|
||||||
IF(ENABLE_XAUDIO2)
|
if(ENABLE_XAUDIO2)
|
||||||
SET( SRC_WX ${SRC_WX} xaudio2.cpp )
|
set(SRC_WX ${SRC_WX} xaudio2.cpp)
|
||||||
ENDIF(ENABLE_XAUDIO2)
|
endif()
|
||||||
|
|
||||||
IF(ENABLE_FAUDIO)
|
if(ENABLE_FAUDIO)
|
||||||
SET( SRC_WX ${SRC_WX} faudio.cpp )
|
set(SRC_WX ${SRC_WX} faudio.cpp)
|
||||||
ENDIF(ENABLE_FAUDIO)
|
endif()
|
||||||
|
|
||||||
IF( WIN32 )
|
if(WIN32)
|
||||||
SET( SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp )
|
set(SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp)
|
||||||
SET(DIRECTX_LIBRARIES dxguid dsound ws2_32)
|
set(DIRECTX_LIBRARIES dxguid dsound ws2_32)
|
||||||
IF(MSVC)
|
if(MSVC)
|
||||||
# workaround for some symbols needed by static SDL2.lib
|
# workaround for some symbols needed by static SDL2.lib
|
||||||
SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} imm32 version)
|
set(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} imm32 version)
|
||||||
ENDIF(MSVC)
|
endif()
|
||||||
# not strictly directx, but win32-related
|
# not strictly directx, but win32-related
|
||||||
IF(ENABLE_DEBUGGER)
|
if(ENABLE_DEBUGGER)
|
||||||
SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} wsock32)
|
set(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} wsock32)
|
||||||
ENDIF(ENABLE_DEBUGGER)
|
endif()
|
||||||
ENDIF( WIN32 )
|
endif()
|
||||||
|
|
||||||
unset(EXTRA_X11_LIBS)
|
|
||||||
if(NOT WIN32 AND NOT APPLE)
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
find_package(X11)
|
find_package(X11)
|
||||||
|
|
||||||
|
@ -670,18 +674,18 @@ if(NOT WIN32 AND NOT APPLE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
link_directories( ${CMAKE_BINARY_DIR} )
|
link_directories(${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
SET(VBAM_ICON vbam.icns)
|
set(VBAM_ICON vbam.icns)
|
||||||
|
|
||||||
SET(VBAM_ICON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/icons/${VBAM_ICON})
|
set(VBAM_ICON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/icons/${VBAM_ICON})
|
||||||
|
|
||||||
IF(APPLE)
|
if(APPLE)
|
||||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
||||||
SET(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks")
|
set(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks")
|
||||||
ENDIF(APPLE)
|
endif()
|
||||||
|
|
||||||
ADD_EXECUTABLE (
|
add_executable(
|
||||||
visualboyadvance-m
|
visualboyadvance-m
|
||||||
WIN32
|
WIN32
|
||||||
MACOSX_BUNDLE
|
MACOSX_BUNDLE
|
||||||
|
@ -693,7 +697,7 @@ ADD_EXECUTABLE (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES (
|
target_link_libraries(
|
||||||
visualboyadvance-m
|
visualboyadvance-m
|
||||||
${VBAMCORE_LIBS}
|
${VBAMCORE_LIBS}
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
|
@ -746,33 +750,36 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF(WIN32)
|
if(WIN32)
|
||||||
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/visualboyadvance-m${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_BINARY_DIR})
|
install(PROGRAMS ${PROJECT_BINARY_DIR}/visualboyadvance-m${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_BINARY_DIR})
|
||||||
ENDIF(WIN32)
|
endif()
|
||||||
IF(NOT WIN32 AND NOT APPLE)
|
|
||||||
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wxvbam.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
ENDIF(NOT WIN32 AND NOT APPLE)
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wxvbam.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# this should set ROM file types correctly
|
# this should set ROM file types correctly
|
||||||
SET_PROPERTY(TARGET visualboyadvance-m APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in)
|
set_property(TARGET visualboyadvance-m APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in)
|
||||||
SET(MACOSX_BUNDLE_ICON_FILE ${VBAM_ICON})
|
set(MACOSX_BUNDLE_ICON_FILE ${VBAM_ICON})
|
||||||
SET_SOURCE_FILES_PROPERTIES(${VBAM_ICON_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
set_source_files_properties(${VBAM_ICON_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||||
|
|
||||||
# bundle dylibs and relink them for releasing .app
|
# bundle dylibs and relink them for releasing .app
|
||||||
# also install translations into the .app
|
# also install translations into the .app
|
||||||
# but only in Release mode
|
# but only in Release mode
|
||||||
IF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
ADD_CUSTOM_COMMAND(TARGET visualboyadvance-m POST_BUILD
|
add_custom_command(
|
||||||
|
TARGET visualboyadvance-m POST_BUILD
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/tools/osx/third_party_libs_tool ./visualboyadvance-m.app
|
COMMAND ${CMAKE_SOURCE_DIR}/tools/osx/third_party_libs_tool ./visualboyadvance-m.app
|
||||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(TARGET visualboyadvance-m POST_BUILD
|
add_custom_command(
|
||||||
|
TARGET visualboyadvance-m POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/mac-translations.cmake
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/mac-translations.cmake
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
ENDIF()
|
endif()
|
||||||
endif(APPLE)
|
endif()
|
||||||
|
|
||||||
SET(WX_EXE_NAME visualboyadvance-m-wx${CMAKE_EXECUTABLE_SUFFIX})
|
set(WX_EXE_NAME visualboyadvance-m-wx${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
|
|
Loading…
Reference in New Issue