Skip to content

Commit 0014735

Browse files
Dekker1chschulte
authored andcommitted
Add installation target to the CMake configuration (#41)
1 parent 0cea598 commit 0014735

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

CMakeLists.txt

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ foreach (lib support kernel search int set float
398398
add_library(gecode${lib} ${sources} ${${libupper}HDR})
399399
target_include_directories(gecode${lib}
400400
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
401+
list(APPEND GECODE_INSTALL_TARGETS gecode${lib})
401402
endif ()
402403
endforeach ()
403404

@@ -433,11 +434,31 @@ if (FLOATSRC)
433434
target_link_libraries(gecodeminimodel gecodefloat)
434435
endif ()
435436

436-
add_executable(gecode-test ${TESTSRC} ${TESTHDR})
437+
add_executable(gecode-test EXCLUDE_FROM_ALL ${TESTSRC} ${TESTHDR})
437438
target_link_libraries(gecode-test gecodeflatzinc gecodeminimodel)
438439

439440
add_executable(fzn-gecode ${FLATZINCEXESRC})
440441
target_link_libraries(fzn-gecode gecodeflatzinc gecodeminimodel gecodedriver)
442+
list(APPEND GECODE_INSTALL_TARGETS fzn-gecode)
443+
444+
set(prefix ${CMAKE_INSTALL_PREFIX})
445+
set(datarootdir \${prefix}/share)
446+
set(datadir \${datarootdir})
447+
if(WIN32)
448+
configure_file(
449+
${PROJECT_SOURCE_DIR}/tools/flatzinc/mzn-gecode.bat.in
450+
${PROJECT_BINARY_DIR}/tools/flatzinc/mzn-gecode.bat
451+
@ONLY
452+
)
453+
set(MZN_SCRIPT ${PROJECT_BINARY_DIR}tools/flatzinc/mzn-gecode.bat)
454+
else()
455+
configure_file(
456+
${PROJECT_SOURCE_DIR}/tools/flatzinc/mzn-gecode.in
457+
${PROJECT_BINARY_DIR}/tools/flatzinc/mzn-gecode
458+
@ONLY
459+
)
460+
set(MZN_SCRIPT ${PROJECT_BINARY_DIR}/tools/flatzinc/mzn-gecode)
461+
endif()
441462

442463
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
443464

@@ -454,3 +475,38 @@ add_test(test gecode-test
454475
-test Int::Arithmetic::Mult::XYZ::Bnd::C
455476
-test Int::Arithmetic::Mult::XYZ::Dom::A
456477
-test Search::BAB::Sol::BalGr::Binary::Binary::Binary::1::1)
478+
479+
## Installation Target
480+
# Install libraries and executables
481+
install(
482+
TARGETS ${GECODE_INSTALL_TARGETS}
483+
RUNTIME DESTINATION bin
484+
LIBRARY DESTINATION lib
485+
ARCHIVE DESTINATION lib
486+
)
487+
install(
488+
FILES ${MZN_SCRIPT}
489+
DESTINATION bin
490+
)
491+
# Install include directory
492+
install(
493+
DIRECTORY gecode
494+
DESTINATION include
495+
FILES_MATCHING
496+
PATTERN "**.hh"
497+
PATTERN "**.hpp"
498+
PATTERN "LICENSE_1_0.txt"
499+
PATTERN "mznlib" EXCLUDE
500+
PATTERN "exampleplugin" EXCLUDE
501+
PATTERN "standalone-example" EXCLUDE
502+
PATTERN "abi*" EXCLUDE
503+
)
504+
install(
505+
FILES ${PROJECT_BINARY_DIR}/gecode/support/config.hpp
506+
DESTINATION include/gecode/support/
507+
)
508+
# Install MiniZinc library
509+
install(
510+
DIRECTORY gecode/flatzinc/mznlib
511+
DESTINATION share/gecode
512+
)

changelog.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ Date: ?-?-?
6868
[DESCRIPTION]
6969
New stuff!
7070

71+
[ENTRY]
72+
Module: other
73+
What: new
74+
Rank: minor
75+
Thanks: Jip J. Dekker
76+
[DESCRIPTION]
77+
Added installation target to the CMake configuration.
78+
7179
[ENTRY]
7280
Module: kernel
7381
What: new

0 commit comments

Comments
 (0)