Try to find pre-compiled wxwidgets on system during build

This commit is contained in:
Caelan Sayler
2024-11-09 14:31:42 +00:00
committed by Caelan
parent 7cd24f8200
commit b791ed5cfe
3 changed files with 51 additions and 15 deletions

View File

@@ -246,12 +246,35 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GTK3
# - name: Install GTK
# run: |
# sudo apt-cache search libwxgt*
# sudo apt-cache search libgtk*
# sudo apt install -y libwxgtk3.0-gtk3-dev libgtk-3-dev
# if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Install wxWidgets (Windows)
working-directory: samples/${{ matrix.sample }}
run: |
vcpkg install wxwidgets
vcpkg integrate install
if: ${{ matrix.sample == 'CPlusPlusWidgets' && matrix.os == 'windows-latest' }}
- name: Install wxWidgets (MacOS)
run: brew install wxwidgets
if: ${{ matrix.sample == 'CPlusPlusWidgets' && matrix.os == 'macos-latest' }}
- name: Install wxWidgets (Linux)
run: |
sudo apt-cache search libwxgt*
sudo apt-cache search libgtk*
sudo apt install -y libwxgtk3.0-gtk3-dev libgtk-3-dev
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.sample == 'CPlusPlusWidgets' && matrix.os == 'ubuntu-latest' }}
# - name: Install wxWidgets
# run: |
# vcpkg install wxwidgets
# vcpkg integrate install
- name: Install VPK
run: dotnet tool install -g vpk
- name: Pack Sample (Windows)

View File

@@ -6,3 +6,4 @@ cmake-build-debug
cmake-build-release
.vscode
.idea
wxWidgets

View File

@@ -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