0
Follow
4
View

Finding wxWidgets on CMake with CMAKE_PREFIX_PATH

dfshi521 注册会员
2023-01-26 04:55

I installed on windows wxWidgets 3.1.4 under C:/wx314_install. It contains the headers and libs file you need for using wxWidgets. After that, you need to set up the different variables for CMake to find the library.

This is my CMakeFile.txt where I say to CMake where to find wxWidgets depending on which mode the program is being compiled, debug, or release. Probably, this last bit can be done differently.

cmake_minimum_required(VERSION 3.20)

message(STATUS "Building SUN")

set(wxWidgets_USE_DEBUG ON)
set(wxWidgets_USE_UNICODE ON)

IF(CMAKE_BUILD_TYPE MATCHES Release)
    message(STATUS "Release mode" )
    set(wxWidgets_ROOT_DIR C:/wx314_install/Release)
    set(wxWidgets_LIB_DIR C:/wx314_install/Release/lib/vc_x64_lib)
    set(wxWidgets_INCLUDE_DIRS C:/wx314_install/Release/include)
ENDIF()

IF(CMAKE_BUILD_TYPE MATCHES Debug)
    message(STATUS "Debug mode" )
    set(wxWidgets_ROOT_DIR "C:/wx314_install/Debug")
    set(wxWidgets_LIB_DIR C:/wx314_install/Debug/lib/vc_x64_lib)
    set(wxWidgets_INCLUDE_DIRS C:/wx314_install/Debug/include)
ENDIF()


message(STATUS "wxWidgets location ${wxWidgets_ROOT_DIR}")
# Note that for MinGW users the order of libs is important!

find_package(wxWidgets REQUIRED net gl core base)

include(${wxWidgets_USE_FILE})

add_executable(app WIN32)

target_sources(app PRIVATE
        src/app.cpp)

target_link_libraries(app PRIVATE ${wxWidgets_LIBRARIES})

This is extracted from this minimal project.

About the Author

Question Info

Publish Time
2023-01-26 04:55
Update Time
2023-01-26 04:55