diff options
author | Tomasz Słodkowicz <slodki@users.noreply.github.com> | 2018-10-04 21:52:30 (GMT) |
---|---|---|
committer | Tomasz Słodkowicz <slodki@users.noreply.github.com> | 2018-10-04 21:52:30 (GMT) |
commit | 0813581859bd61a9d30c97aa893030bea85f134e (patch) | |
tree | e4c0127747623e16c5653bcae08933e9eb09632a /Modules/FindwxWidgets.cmake | |
parent | 0abf88f6f618bd08933f8c817f0c4ac07b0bc52c (diff) | |
download | CMake-0813581859bd61a9d30c97aa893030bea85f134e.zip CMake-0813581859bd61a9d30c97aa893030bea85f134e.tar.gz CMake-0813581859bd61a9d30c97aa893030bea85f134e.tar.bz2 |
FindwxWidgets: honor OPTIONAL_COMPONENTS
Diffstat (limited to 'Modules/FindwxWidgets.cmake')
-rw-r--r-- | Modules/FindwxWidgets.cmake | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index f2d6285..e61c84e 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -12,7 +12,7 @@ # modules that you will use, you need to name them as components to the # package: # -# find_package(wxWidgets COMPONENTS core base ...) +# find_package(wxWidgets COMPONENTS core base ... OPTIONAL_COMPONENTS net ...) # # There are two search branches: a windows style and a unix style. For # windows, the following variables are searched for and set to defaults @@ -89,7 +89,7 @@ # :: # # # Note that for MinGW users the order of libs is important! -# find_package(wxWidgets COMPONENTS net gl core base) +# find_package(wxWidgets COMPONENTS gl core base OPTIONAL_COMPONENTS net) # if(wxWidgets_FOUND) # include(${wxWidgets_USE_FILE}) # # and for each of your dependent executable/library targets: @@ -102,7 +102,7 @@ # # :: # -# find_package(wxWidgets REQUIRED net gl core base) +# find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net) # include(${wxWidgets_USE_FILE}) # # and for each of your dependent executable/library targets: # target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) @@ -396,6 +396,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") list(APPEND wxWidgets_LIBRARIES debug ${WX_${LIB}d} optimized ${WX_${LIB}} ) + elseif(NOT wxWidgets_FIND_REQUIRED_${LIB}) + DBG_MSG_V("- ignored optional missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}") else() DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}") set(wxWidgets_FOUND FALSE) @@ -408,9 +410,10 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") if(WX_${LIB}${_DBG}) DBG_MSG_V("Found ${LIB}${_DBG}") list(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}}) + elseif(NOT wxWidgets_FIND_REQUIRED_${LIB}) + DBG_MSG_V("- ignored optional missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}") else() - DBG_MSG_V( - "- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}") + DBG_MSG_V("- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}") set(wxWidgets_FOUND FALSE) endif() endforeach() @@ -803,11 +806,24 @@ else() # - NOTE: wx-config doesn't verify that the libs requested exist # it just produces the names. Maybe a TRY_COMPILE would # be useful here... - string(REPLACE ";" "," - wxWidgets_FIND_COMPONENTS "${wxWidgets_FIND_COMPONENTS}") + unset(_cmp_req) + unset(_cmp_opt) + foreach(_cmp IN LISTS wxWidgets_FIND_COMPONENTS) + if(wxWidgets_FIND_REQUIRED_${_cmp}) + list(APPEND _cmp_req "${_cmp}") + else() + list(APPEND _cmp_opt "${_cmp}") + endif() + endforeach() + DBG_MSG_V("wxWidgets required components : ${_cmp_req}") + DBG_MSG_V("wxWidgets optional components : ${_cmp_opt}") + if(DEFINED _cmp_opt) + string(REPLACE ";" "," _cmp_opt "--optional-libs ${_cmp_opt}") + endif() + string(REPLACE ";" "," _cmp_req "${_cmp_req}") execute_process( COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" - ${wxWidgets_SELECT_OPTIONS} --libs ${wxWidgets_FIND_COMPONENTS} + ${wxWidgets_SELECT_OPTIONS} --libs ${_cmp_req} ${_cmp_opt} OUTPUT_VARIABLE wxWidgets_LIBRARIES RESULT_VARIABLE RET ERROR_QUIET @@ -833,8 +849,10 @@ else() else() set(wxWidgets_FOUND FALSE) - DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxWidgets_FIND_COMPONENTS} FAILED with RET=${RET}") + DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${_cmp_req} ${_cmp_opt} FAILED with RET=${RET}") endif() + unset(_cmp_req) + unset(_cmp_opt) endif() # When using wx-config in MSYS, the include paths are UNIX style paths which may or may |