From 8e7648f42a8e32a9fff3309a52650e8904a6de97 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Tue, 25 Apr 2017 09:37:11 -0700 Subject: [PATCH] CMake: modern-ize wxWidgets --- Externals/wxWidgets3/CMakeLists.txt | 61 ++++++++++++----------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/Externals/wxWidgets3/CMakeLists.txt b/Externals/wxWidgets3/CMakeLists.txt index 113c8c511a..36adfa3e44 100644 --- a/Externals/wxWidgets3/CMakeLists.txt +++ b/Externals/wxWidgets3/CMakeLists.txt @@ -818,23 +818,20 @@ set(SRCS_UNIXGTK "src/unix/uiactionx11.cpp" "src/unix/utilsx11.cpp") -include_directories(.) -include_directories(include) - -set(SRCS - ${SRCS_AUI} - ${SRCS_COMMON} - ${SRCS_GENERIC}) +add_library(wx STATIC ${SRCS_AUI} ${SRCS_COMMON} ${SRCS_GENERIC}) +target_include_directories(wx PUBLIC . include) +target_compile_definitions(wx PRIVATE "WXBUILDING") +# wxWidgets warnings are not our problem. +target_compile_options(wx PRIVATE "-w") if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98") - add_definitions(-D__WXOSX_COCOA__) - set(SRCS - ${SRCS} + target_compile_definitions(wx PRIVATE "__WXOSX_COCOA__") + target_sources(wx PRIVATE ${SRCS_GENERICOSX} ${SRCS_OSX} - ${SRCS_UNIX}) - set(LIBS + ${SRCS_UNIX} + ) + target_link_libraries(wx PRIVATE png iconv ${APPKIT_LIBRARY} @@ -847,23 +844,23 @@ if(APPLE) ${OPENGL_LIBRARY} ) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") - if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - add_definitions(-D__LINUX__=1) + target_compile_options(wx PRIVATE "$<$:-std=gnu++11>") + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_compile_definitions(wx PRIVATE "__LINUX__=1") else() - add_definitions(-D__BSD__=1) + target_compile_definitions(wx PRIVATE "__BSD__=1") endif() - add_definitions(-D__WXGTK__) - set(SRCS - ${SRCS} + target_compile_definitions(wx PRIVATE "__WXGTK__") + target_sources(wx PRIVATE ${SRCS_GENERICGTK} ${SRCS_GTK} ${SRCS_UNIX} - ${SRCS_UNIXGTK}) + ${SRCS_UNIXGTK} + ) if (NOT X11_xf86vmode_FOUND OR NOT X11_Xinerama_FOUND) message(FATAL_ERROR "wxGTK2 needs Xinerama and Xxf86vm") endif() - set(LIBS + target_link_libraries(wx PRIVATE png ${GTHREAD2_LIBRARIES} ${PANGOCAIRO_LIBRARIES} @@ -871,25 +868,19 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD") ${Backtrace_LIBRARY} ${X11_X11_LIB} ${X11_Xxf86vm_LIB} - ${X11_Xinerama_LIB}) + ${X11_Xinerama_LIB} + ) else() - add_definitions(-D__WXMSW__) - add_definitions(-DNOPCH) remove_definitions(-DWIN32_LEAN_AND_MEAN) - set(SRCS - ${SRCS} + target_compile_definitions(wx PRIVATE "__WXMSW__" "NOPCH") + target_sources(wx PRIVATE ${SRCS_GENERICMSW} - ${SRCS_MSW}) - set(LIBS + ${SRCS_MSW} + ) + target_link_libraries(wx PRIVATE Comctl32.lib Rpcrt4.lib ${OPENGL_LIBRARIES} ) 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})