mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Try to find pre-compiled wxwidgets on system during build
This commit is contained in:
3
samples/CPlusPlusWidgets/.gitignore
vendored
3
samples/CPlusPlusWidgets/.gitignore
vendored
@@ -5,4 +5,5 @@ build-rel
|
||||
cmake-build-debug
|
||||
cmake-build-release
|
||||
.vscode
|
||||
.idea
|
||||
.idea
|
||||
wxWidgets
|
||||
@@ -9,33 +9,45 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(wxBUILD_SHARED OFF)
|
||||
|
||||
message(STATUS "Fetching wxWidgets...")
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/wxWidgets")
|
||||
set(wxWidgets_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/wxWidgets")
|
||||
set(wxWidgets_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/wxWidgets/lib/vc14x_x64_dll")
|
||||
set(wxWidgets_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/wxWidgets/include")
|
||||
endif()
|
||||
|
||||
find_package(wxWidgets COMPONENTS net core base)
|
||||
if(wxWidgets_USE_FILE) # not defined in CONFIG mode
|
||||
include(${wxWidgets_USE_FILE})
|
||||
endif()
|
||||
|
||||
if(NOT wxWidgets_FOUND)
|
||||
message(STATUS "wxWidgets not found. Fetching wxWidgets from git...")
|
||||
FetchContent_Declare(
|
||||
wxWidgets
|
||||
GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
|
||||
GIT_SHALLOW ON
|
||||
)
|
||||
FetchContent_MakeAvailable(wxWidgets)
|
||||
set(wxWidgets_LIBRARIES wxcore wxnet)
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
wxWidgets
|
||||
GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
|
||||
GIT_SHALLOW ON
|
||||
)
|
||||
FetchContent_MakeAvailable(wxWidgets)
|
||||
|
||||
# include the Velopack library (headers + precompiled lib)
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../src/lib-cpp/include")
|
||||
set(VELOPACK_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug/velopack_libc.dll.lib")
|
||||
set(VELOPACK_DLL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug/velopack_libc.dll")
|
||||
|
||||
# add sources and executable
|
||||
set(SRCS main.cpp)
|
||||
if(WIN32)
|
||||
# the WIN32 is needed for Windows in order for it to look for WinMain
|
||||
# instead of the main function. This is ignored on other systems,
|
||||
# so it works on all platforms
|
||||
add_executable(main WIN32 ${SRCS} main.exe.manifest)
|
||||
add_executable(main WIN32 main.cpp main.exe.manifest)
|
||||
else()
|
||||
add_executable(main ${SRCS})
|
||||
add_executable(main main.cpp)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(main PRIVATE RELEASES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/releases")
|
||||
target_link_libraries(main PRIVATE wxcore wxnet "${VELOPACK_LIB_PATH}")
|
||||
target_link_libraries(main PRIVATE ${wxWidgets_LIBRARIES} "${VELOPACK_LIB_PATH}")
|
||||
|
||||
# copy velopack dll to output directory
|
||||
add_custom_command(TARGET main POST_BUILD
|
||||
|
||||
Reference in New Issue
Block a user