Skip to content

Commit 6029814

Browse files
committed
Use CPM to fetch wxwidgets
1 parent accb84e commit 6029814

File tree

4 files changed

+104
-2
lines changed

4 files changed

+104
-2
lines changed

Diff for: .github/workflows/cmake.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CMake
2+
3+
on: [workflow_dispatch, push, pull_request]
4+
5+
6+
concurrency:
7+
group: FC-CI-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
env:
11+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
12+
BUILD_TYPE: Release
13+
CPM_SOURCE_CACHE: ~/.cache/CPM
14+
15+
- name: Cache CPM dependency packages
16+
uses: actions/cache@v3
17+
with:
18+
path: |
19+
${{ CPM_SOURCE_CACHE ))
20+
21+
jobs:
22+
build:
23+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
24+
# You can convert this to a matrix build if you need cross-platform coverage.
25+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
26+
runs-on: ubuntu-22.04
27+
- name: Install I-SIMPA dependencies
28+
run: |
29+
sudo apt-get update -qq
30+
sudo apt-get install -y --no-install-recommends \
31+
libboost-all-dev \
32+
python3-dev \
33+
swig
34+
steps:
35+
- uses: actions/checkout@v3
36+
37+
- name: Configure CMake
38+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
39+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
40+
run: |
41+
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
42+
43+
- name: Build
44+
# Compile i-simpa
45+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
46+
47+
- name: Install
48+
# Copy stuff to bin subdirectory for "standalone" application
49+
run: cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
50+
51+
- name: Test
52+
working-directory: ${{github.workspace}}/build
53+
# Execute tests defined by the CMake configuration.
54+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
55+
run: ctest -C ${{env.BUILD_TYPE}}
56+

Diff for: CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0)
1+
# begin basic metadata
2+
# minimum CMake version required for C++20 support, among other things
3+
cmake_minimum_required(VERSION 3.15)
24

35
# Maps to a solution file (isimpa.sln). The solution will
46
# have all targets (exe, lib, dll) as projects (.vcproj)
57
project (isimpa VERSION 1.3.4)
68

9+
# a better way to load dependencies
10+
include(cmake/CPM.cmake)
711

812
# convert path of a .lib file into a .dll file
913
# findboost does not store .dll locations

Diff for: cmake/CPM.cmake

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
set(CPM_DOWNLOAD_VERSION 0.37.0)
2+
3+
if(CPM_SOURCE_CACHE)
4+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
5+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
6+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7+
else()
8+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9+
endif()
10+
11+
# Expand relative path. This is important if the provided path contains a tilde (~)
12+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
13+
14+
function(download_cpm)
15+
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
16+
file(DOWNLOAD
17+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
18+
${CPM_DOWNLOAD_LOCATION}
19+
)
20+
endfunction()
21+
22+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
23+
download_cpm()
24+
else()
25+
# resume download if it previously failed
26+
file(READ ${CPM_DOWNLOAD_LOCATION} check)
27+
if("${check}" STREQUAL "")
28+
download_cpm()
29+
endif()
30+
endif()
31+
32+
include(${CPM_DOWNLOAD_LOCATION})

Diff for: src/isimpa/CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,16 @@ set(Boost_USE_STATIC_LIBS OFF)
390390
find_package(Boost REQUIRED COMPONENTS system python filesystem regex)
391391
link_directories( ${Boost_LIBRARY_DIRS} )
392392

393+
394+
# add wxWidgets as dependency
395+
CPMFindPackage(
396+
NAME wxWidgets
397+
GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets
398+
GIT_TAG v3.1.4
399+
EXCLUDE_FROM_ALL YES
400+
)
401+
402+
393403
# Set Properties->General->Configuration Type to Application
394404
# Creates isimpa with the listed sources
395405
# Adds sources to the Solution Explorer
@@ -456,7 +466,7 @@ find_package(wxWidgets COMPONENTS core base xml gl aui adv html REQUIRED)
456466
include(${wxWidgets_USE_FILE})
457467
# Find package for buildingfind_package(Python3 COMPONENTS Interpreter Development)
458468
FIND_PACKAGE(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED)
459-
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import get_python_lib; print(get_python_lib().split(sys.prefix)[-1][1:])"
469+
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; import sysconfig; print(list(sysconfig.get_paths().values()))"
460470
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
461471

462472
find_package(OpenGL REQUIRED)

0 commit comments

Comments
 (0)