1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5UsewxWidgets 6------------ 7 8Convenience include for using wxWidgets library. 9 10Determines if wxWidgets was FOUND and sets the appropriate libs, 11incdirs, flags, etc. INCLUDE_DIRECTORIES and LINK_DIRECTORIES are 12called. 13 14USAGE 15 16:: 17 18 # Note that for MinGW users the order of libs is important! 19 find_package(wxWidgets REQUIRED net gl core base) 20 include(${wxWidgets_USE_FILE}) 21 # and for each of your dependent executable/library targets: 22 target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) 23 24 25 26DEPRECATED 27 28:: 29 30 LINK_LIBRARIES is not called in favor of adding dependencies per target. 31 32 33 34AUTHOR 35 36:: 37 38 Jan Woetzel <jw -at- mip.informatik.uni-kiel.de> 39#]=======================================================================] 40 41# debug message and logging. 42# comment these out for distribution 43if (NOT LOGFILE ) 44 # set(LOGFILE "${PROJECT_BINARY_DIR}/CMakeOutput.log") 45endif () 46macro(MSG _MSG) 47 # file(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}\n") 48 # message(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") 49endmacro() 50 51 52MSG("wxWidgets_FOUND=${wxWidgets_FOUND}") 53if (wxWidgets_FOUND) 54 if (wxWidgets_INCLUDE_DIRS) 55 if(wxWidgets_INCLUDE_DIRS_NO_SYSTEM) 56 include_directories(${wxWidgets_INCLUDE_DIRS}) 57 else() 58 include_directories(SYSTEM ${wxWidgets_INCLUDE_DIRS}) 59 endif() 60 MSG("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}") 61 endif() 62 63 if (wxWidgets_LIBRARY_DIRS) 64 link_directories(${wxWidgets_LIBRARY_DIRS}) 65 MSG("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}") 66 endif() 67 68 if (wxWidgets_DEFINITIONS) 69 set_property(DIRECTORY APPEND 70 PROPERTY COMPILE_DEFINITIONS ${wxWidgets_DEFINITIONS}) 71 MSG("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}") 72 endif() 73 74 if (wxWidgets_DEFINITIONS_DEBUG) 75 set_property(DIRECTORY APPEND 76 PROPERTY COMPILE_DEFINITIONS_DEBUG ${wxWidgets_DEFINITIONS_DEBUG}) 77 MSG("wxWidgets_DEFINITIONS_DEBUG=${wxWidgets_DEFINITIONS_DEBUG}") 78 endif() 79 80 if (wxWidgets_CXX_FLAGS) 81 # Flags are expected to be a string here, not a list. 82 string(REPLACE ";" " " wxWidgets_CXX_FLAGS_str "${wxWidgets_CXX_FLAGS}") 83 string(APPEND CMAKE_CXX_FLAGS " ${wxWidgets_CXX_FLAGS_str}") 84 MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS_str}") 85 unset(wxWidgets_CXX_FLAGS_str) 86 endif() 87 88 # DEPRECATED JW 89 # just for backward compatibility: add deps to all targets 90 # library projects better use advanced find_package(wxWidgets) directly. 91 #if(wxWidgets_LIBRARIES) 92 # link_libraries(${wxWidgets_LIBRARIES}) 93 # # BUG: str too long: MSG("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}") 94 # if(LOGFILE) 95 # file(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${wxWidgets_LIBRARIES}\n") 96 # endif() 97 #endif() 98 99else () 100 message("wxWidgets requested but not found.") 101endif() 102