I am trying to use find_package to find wxWidgets, which is placed inside the location pointed to my CMAKE_PREFIX_PATH, however I am not succeeding.
If I set the environment variable WXWIDGETS_ROOT_DIR to the wxWidgets installation, then all works fine. However, if I set CMAKE_PREFIX_PATH to the folder containing my folder wxWidgets-3.1.4, wx is not found.
How can I fix this? Where is there documentation on the fact that WXWIDGETS_ROOT_DIR needs to be used? I only found this out through another stack overflow post.
My CMakeLists.txt:
####################
# Global #
####################
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 17)
#####################
# Project #
#####################
# Header files (relative to "include" directory)
set(HEADERS
app.h
)
# Source files (relative to "src" directory)
set(SOURCES
app.cpp
)
# Compiler definitions
set(DEFINES
)
# Compiler options
set(OPTIONS
)
# Project setup
project("CPP-Sandbox"
VERSION "0.0.1"
DESCRIPTION "Description"
LANGUAGES CXX)
add_executable(CPP-Sandbox)
list(TRANSFORM HEADERS PREPEND "include/")
list(TRANSFORM SOURCES PREPEND "src/")
target_include_directories(CPP-Sandbox PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(CPP-Sandbox PRIVATE ${SOURCES} ${HEADERS})
target_compile_definitions(CPP-Sandbox PRIVATE ${DEFINES})
target_compile_options(CPP-Sandbox PRIVATE ${OPTIONS})
set_target_properties(CPP-Sandbox PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "bin"
WIN32_EXECUTABLE true
)
####################
# Dependencies #
####################
find_package(wxWidgets REQUIRED COMPONENTS core base)
include(${wxWidgets_USE_FILE})
target_link_libraries(CPP-Sandbox ${wxWidgets_LIBRARIES})
