CMake: modern-ize wxWidgets

This commit is contained in:
Michael Maltese 2017-04-25 09:37:11 -07:00
parent f7892faa80
commit 8e7648f42a
1 changed files with 26 additions and 35 deletions

View File

@ -818,23 +818,20 @@ set(SRCS_UNIXGTK
"src/unix/uiactionx11.cpp" "src/unix/uiactionx11.cpp"
"src/unix/utilsx11.cpp") "src/unix/utilsx11.cpp")
include_directories(.) add_library(wx STATIC ${SRCS_AUI} ${SRCS_COMMON} ${SRCS_GENERIC})
include_directories(include) target_include_directories(wx PUBLIC . include)
target_compile_definitions(wx PRIVATE "WXBUILDING")
set(SRCS # wxWidgets warnings are not our problem.
${SRCS_AUI} target_compile_options(wx PRIVATE "-w")
${SRCS_COMMON}
${SRCS_GENERIC})
if(APPLE) if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98") target_compile_definitions(wx PRIVATE "__WXOSX_COCOA__")
add_definitions(-D__WXOSX_COCOA__) target_sources(wx PRIVATE
set(SRCS
${SRCS}
${SRCS_GENERICOSX} ${SRCS_GENERICOSX}
${SRCS_OSX} ${SRCS_OSX}
${SRCS_UNIX}) ${SRCS_UNIX}
set(LIBS )
target_link_libraries(wx PRIVATE
png png
iconv iconv
${APPKIT_LIBRARY} ${APPKIT_LIBRARY}
@ -847,23 +844,23 @@ if(APPLE)
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
) )
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") target_compile_options(wx PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-std=gnu++11>")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-D__LINUX__=1) target_compile_definitions(wx PRIVATE "__LINUX__=1")
else() else()
add_definitions(-D__BSD__=1) target_compile_definitions(wx PRIVATE "__BSD__=1")
endif() endif()
add_definitions(-D__WXGTK__) target_compile_definitions(wx PRIVATE "__WXGTK__")
set(SRCS target_sources(wx PRIVATE
${SRCS}
${SRCS_GENERICGTK} ${SRCS_GENERICGTK}
${SRCS_GTK} ${SRCS_GTK}
${SRCS_UNIX} ${SRCS_UNIX}
${SRCS_UNIXGTK}) ${SRCS_UNIXGTK}
)
if (NOT X11_xf86vmode_FOUND OR NOT X11_Xinerama_FOUND) if (NOT X11_xf86vmode_FOUND OR NOT X11_Xinerama_FOUND)
message(FATAL_ERROR "wxGTK2 needs Xinerama and Xxf86vm") message(FATAL_ERROR "wxGTK2 needs Xinerama and Xxf86vm")
endif() endif()
set(LIBS target_link_libraries(wx PRIVATE
png png
${GTHREAD2_LIBRARIES} ${GTHREAD2_LIBRARIES}
${PANGOCAIRO_LIBRARIES} ${PANGOCAIRO_LIBRARIES}
@ -871,25 +868,19 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD")
${Backtrace_LIBRARY} ${Backtrace_LIBRARY}
${X11_X11_LIB} ${X11_X11_LIB}
${X11_Xxf86vm_LIB} ${X11_Xxf86vm_LIB}
${X11_Xinerama_LIB}) ${X11_Xinerama_LIB}
)
else() else()
add_definitions(-D__WXMSW__)
add_definitions(-DNOPCH)
remove_definitions(-DWIN32_LEAN_AND_MEAN) remove_definitions(-DWIN32_LEAN_AND_MEAN)
set(SRCS target_compile_definitions(wx PRIVATE "__WXMSW__" "NOPCH")
${SRCS} target_sources(wx PRIVATE
${SRCS_GENERICMSW} ${SRCS_GENERICMSW}
${SRCS_MSW}) ${SRCS_MSW}
set(LIBS )
target_link_libraries(wx PRIVATE
Comctl32.lib Comctl32.lib
Rpcrt4.lib Rpcrt4.lib
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
) )
endif() endif()
add_definitions(-DWXBUILDING)
# wxWidgets warnings are not our problem.
add_definitions(-w)
add_library(wx STATIC ${PNG_SRCS} ${SRCS})
target_link_libraries(wx ${LIBS})