Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/ci/cmake-example-feature-smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail

source_dir="${GITHUB_WORKSPACE:-$(pwd)}"
build_root="${RUNNER_TEMP:-/tmp}/gecode-example-features"

rm -rf "$build_root"

cmake -S "$source_dir" -B "$build_root/int" -G Ninja \
-DGECODE_ENABLE_EXAMPLES=ON \
-DGECODE_ENABLE_SET_VARS=OFF \
-DGECODE_ENABLE_FLOAT_VARS=OFF \
-DGECODE_ENABLE_FLATZINC=OFF \
-DGECODE_ENABLE_QT=OFF \
-DGECODE_ENABLE_GIST=OFF

grep -q '^GECODE_ENABLE_SET_VARS:BOOL=OFF$' "$build_root/int/CMakeCache.txt"
grep -q '^GECODE_ENABLE_FLOAT_VARS:BOOL=OFF$' "$build_root/int/CMakeCache.txt"
cmake --build "$build_root/int" --target help > "$build_root/int-targets.txt"
grep -q '^tsp:' "$build_root/int-targets.txt"
! grep -q '^crew:' "$build_root/int-targets.txt"
! grep -q '^cartesian-heart:' "$build_root/int-targets.txt"
! grep -q '^archimedean-spiral:' "$build_root/int-targets.txt"
cmake --build "$build_root/int" --target tsp

cmake -S "$source_dir" -B "$build_root/optional" -G Ninja \
-DGECODE_ENABLE_EXAMPLES=ON \
-DGECODE_ENABLE_SET_VARS=ON \
-DGECODE_ENABLE_FLOAT_VARS=ON \
-DGECODE_ENABLE_MPFR=OFF \
-DGECODE_ENABLE_FLATZINC=OFF \
-DGECODE_ENABLE_QT=OFF \
-DGECODE_ENABLE_GIST=OFF

cmake --build "$build_root/optional" --target help > "$build_root/optional-targets.txt"
grep -q '^crew:' "$build_root/optional-targets.txt"
grep -q '^cartesian-heart:' "$build_root/optional-targets.txt"
! grep -q '^archimedean-spiral:' "$build_root/optional-targets.txt"
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ jobs:
shell: bash
run: cmake --build "$GITHUB_WORKSPACE/build-ninja"

- name: Example feature selection
shell: bash
run: bash .github/ci/cmake-example-feature-smoke.sh

- name: Check
shell: bash
run: >
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ endif()
if(GECODE_ENABLE_MINIMODEL)
gecode_force_option_on(GECODE_ENABLE_SEARCH "Minimodel requires search")
gecode_force_option_on(GECODE_ENABLE_INT_VARS "Minimodel requires int variables")
gecode_force_option_on(GECODE_ENABLE_SET_VARS "Minimodel requires set variables")
endif()
if(GECODE_ENABLE_DRIVER)
gecode_force_option_on(GECODE_ENABLE_SEARCH "Driver requires search")
Expand All @@ -267,8 +266,6 @@ endif()
if(GECODE_ENABLE_EXAMPLES)
gecode_force_option_on(GECODE_ENABLE_SEARCH "Examples require search")
gecode_force_option_on(GECODE_ENABLE_INT_VARS "Examples require int variables")
gecode_force_option_on(GECODE_ENABLE_SET_VARS "Examples require set variables")
gecode_force_option_on(GECODE_ENABLE_FLOAT_VARS "Examples require float variables")
gecode_force_option_on(GECODE_ENABLE_MINIMODEL "Examples require minimodel")
gecode_force_option_on(GECODE_ENABLE_DRIVER "Examples require driver")
endif()
Expand Down Expand Up @@ -1271,7 +1268,10 @@ if(GECODE_ENABLE_FLOAT_VARS)
endif()
endif()
if(GECODE_ENABLE_MINIMODEL)
set(mm_deps int set search)
set(mm_deps int search)
if(GECODE_ENABLE_SET_VARS)
list(APPEND mm_deps set)
endif()
if(GECODE_ENABLE_FLOAT_VARS)
list(APPEND mm_deps float)
endif()
Expand Down
9 changes: 9 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ Thanks: Ioannis Papatsoris
Treat zero entries in the TSP example as valid zero-cost edges. This lets the
br17 instance reach its optimum.

[ENTRY]
Module: example
What: bug
Rank: minor
Issue: 83
[DESCRIPTION]
Build CMake examples only when their required variable modules and MPFR support
are enabled.

[ENTRY]
Module: flatzinc
What: new
Expand Down
25 changes: 23 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,35 @@ set(GECODE_EXAMPLE_SOURCES
warehouses.cpp
word-square.cpp)

set(GECODE_MPFR_EXAMPLES
set(GECODE_SET_EXAMPLES
crew
golf
hamming
queen-armies
steiner)

set(GECODE_FLOAT_EXAMPLES
cartesian-heart
descartes-folium)

set(GECODE_MPFR_FLOAT_EXAMPLES
archimedean-spiral
golden-spiral)

function(gecode_add_example source_file)
get_filename_component(example_name "${source_file}" NAME_WE)

if(example_name IN_LIST GECODE_MPFR_EXAMPLES AND
if(example_name IN_LIST GECODE_SET_EXAMPLES AND NOT GECODE_ENABLE_SET_VARS)
message(STATUS "Skipping example: ${example_name} (requires set variables)")
return()
endif()

if(example_name IN_LIST GECODE_FLOAT_EXAMPLES AND NOT GECODE_ENABLE_FLOAT_VARS)
message(STATUS "Skipping example: ${example_name} (requires float variables)")
return()
endif()

if(example_name IN_LIST GECODE_MPFR_FLOAT_EXAMPLES AND
(NOT GECODE_ENABLE_FLOAT_VARS OR NOT GECODE_ENABLE_MPFR OR NOT MPFR_FOUND))
message(STATUS "Skipping example: ${example_name} (requires MPFR float support)")
return()
Expand Down
Loading