Repository navigation
Expand file tree
/
Copy pathcpp.cmake
More file actions
1124 lines (1048 loc) · 36 KB
/
Copy pathcpp.cmake
File metadata and controls
1124 lines (1048 loc) · 36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2010-2025 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Check primitive types
option(CHECK_TYPE "Check primitive type size" OFF)
if(CHECK_TYPE)
include(CMakePushCheckState)
cmake_push_check_state(RESET)
set(CMAKE_EXTRA_INCLUDE_FILES "cstdint")
include(CheckTypeSize)
check_type_size("long" SIZEOF_LONG LANGUAGE CXX)
message(STATUS "Found long size: ${SIZEOF_LONG}")
check_type_size("long long" SIZEOF_LONG_LONG LANGUAGE CXX)
message(STATUS "Found long long size: ${SIZEOF_LONG_LONG}")
check_type_size("int64_t" SIZEOF_INT64_T LANGUAGE CXX)
message(STATUS "Found int64_t size: ${SIZEOF_INT64_T}")
check_type_size("unsigned long" SIZEOF_ULONG LANGUAGE CXX)
message(STATUS "Found unsigned long size: ${SIZEOF_ULONG}")
check_type_size("unsigned long long" SIZEOF_ULONG_LONG LANGUAGE CXX)
message(STATUS "Found unsigned long long size: ${SIZEOF_ULONG_LONG}")
check_type_size("uint64_t" SIZEOF_UINT64_T LANGUAGE CXX)
message(STATUS "Found uint64_t size: ${SIZEOF_UINT64_T}")
check_type_size("int *" SIZEOF_INT_P LANGUAGE CXX)
message(STATUS "Found int * size: ${SIZEOF_INT_P}")
check_type_size("intptr_t" SIZEOF_INTPTR_T LANGUAGE CXX)
message(STATUS "Found intptr_t size: ${SIZEOF_INTPTR_T}")
check_type_size("uintptr_t" SIZEOF_UINTPTR_T LANGUAGE CXX)
message(STATUS "Found uintptr_t size: ${SIZEOF_UINTPTR_T}")
cmake_pop_check_state()
endif()
# see: https://semver.org/
if(RELEASE)
set(CXX_RELEASE "")
else()
set(CXX_RELEASE "-rc.${RC_VERSION}")
endif()
#############
## FLAGS ##
#############
set(OR_TOOLS_COMPILE_DEFINITIONS)
set(OR_TOOLS_COMPILE_OPTIONS)
set(OR_TOOLS_TEST_COMPILE_OPTIONS)
set(OR_TOOLS_LINK_OPTIONS)
if(MSVC AND BUILD_SHARED_LIBS)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "OR_BUILD_DLL")
endif()
# Optional built-in components
if(BUILD_MATH_OPT)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_MATH_OPT")
endif()
# Optional solvers
if(USE_BOP)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_BOP")
endif()
if(USE_COINOR)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS
"USE_CBC" # enable COIN-OR CBC support
"USE_CLP" # enable COIN-OR CLP support
)
endif()
if(USE_GLOP)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_GLOP")
endif()
if(USE_GLPK)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_GLPK")
endif()
if(USE_HIGHS)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_HIGHS")
endif()
if(USE_PDLP)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_PDLP")
set(PDLP_DIR pdlp)
endif()
if(USE_SCIP)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_SCIP")
endif()
if(USE_CPLEX)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_CPLEX")
endif()
if(WIN32)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "__WIN32__")
endif()
# Compiler options
include(${PROJECT_SOURCE_DIR}/ortools/copts/GENERATED_ORToolsCopts.cmake)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "QCC")
set(OR_TOOLS_COMPILE_OPTIONS "${ORTOOLS_GCC_FLAGS}")
set(OR_TOOLS_TEST_COMPILE_OPTIONS "${ORTOOLS_GCC_TEST_FLAGS}")
set(OR_TOOLS_LINK_OPTIONS "${ORTOOLS_GCC_LINKOPTS}")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # MATCHES so we get both Clang and AppleClang
if(MSVC)
# clang-cl is half MSVC, half LLVM
set(OR_TOOLS_COMPILE_OPTIONS "${ORTOOLS_CLANG_CL_FLAGS}")
set(OR_TOOLS_TEST_COMPILE_OPTIONS "${ORTOOLS_CLANG_CL_TEST_FLAGS}")
set(OR_TOOLS_LINK_OPTIONS "${ORTOOLS_CLANG_CL_LINKOPTS}")
else()
set(OR_TOOLS_COMPILE_OPTIONS "${ORTOOLS_LLVM_FLAGS}")
set(OR_TOOLS_TEST_COMPILE_OPTIONS "${ORTOOLS_LLVM_TEST_FLAGS}")
set(OR_TOOLS_LINK_OPTIONS "${ORTOOLS_LLVM_LINKOPTS}")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
# IntelLLVM is similar to Clang, with some additional flags.
if(MSVC)
# clang-cl is half MSVC, half LLVM
set(OR_TOOLS_COMPILE_OPTIONS "${ORTOOLS_CLANG_CL_FLAGS}")
set(OR_TOOLS_TEST_COMPILE_OPTIONS "${ORTOOLS_CLANG_CL_TEST_FLAGS}")
set(OR_TOOLS_LINK_OPTIONS "${ORTOOLS_CLANG_CL_LINKOPTS}")
else()
set(OR_TOOLS_COMPILE_OPTIONS "${ORTOOLS_LLVM_FLAGS}")
set(OR_TOOLS_TEST_COMPILE_OPTIONS "${ORTOOLS_LLVM_TEST_FLAGS}")
set(OR_TOOLS_LINK_OPTIONS "${ORTOOLS_LLVM_LINKOPTS}")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(OR_TOOLS_COMPILE_OPTIONS "${ORTOOLS_MSVC_FLAGS}")
set(OR_TOOLS_TEST_COMPILE_OPTIONS "${ORTOOLS_MSVC_TEST_FLAGS}")
set(OR_TOOLS_LINK_OPTIONS "${ORTOOLS_MSVC_LINKOPTS}")
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}. Building with no default flags")
set(OR_TOOLS_COMPILE_OPTIONS "")
set(OR_TOOLS_TEST_COMPILE_OPTIONS "")
set(OR_TOOLS_LINK_OPTIONS "")
endif()
# These flags are currently not defined in ortools/copts/GENERATED_ORToolsCopts.cmake
# Check if we need to add them.
# if(MSVC)
# list(APPEND OR_TOOLS_COMPILE_OPTIONS
# "/Zc:inline" # Remove unreferenced COMDAT
# "/fp:precise"
# )
# # MSVC warning suppressions
# list(APPEND OR_TOOLS_COMPILE_OPTIONS
# "/wd4065" # switch statement contains 'default' but no 'case' labels
# "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
# "/wd4200" # nonstandard extension used : zero-sized array in struct/union
# "/wd4251" # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
# "/wd4305" # 'identifier' : truncation from 'type1' to 'type2'
# "/wd4307" # 'operator' : integral constant overflow
# "/wd4309" # 'conversion' : truncation of constant value
# "/wd4334" # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
# "/wd4355" # 'this' : used in base member initializer list
# "/wd4477" # 'fwprintf' : format string '%s' requires an argument of type 'wchar_t *'
# "/wd4506" # no definition for inline function 'function'
# "/wd4715" # function' : not all control paths return a value
# "/wd4996" # The compiler encountered a deprecated declaration.
# )
# else()
# list(APPEND OR_TOOLS_COMPILE_OPTIONS
# "-fwrapv"
# )
# endif()
################
## C++ Test ##
################
# ortools_cxx_test()
# CMake function to generate and build C++ test.
# Parameters:
# NAME: CMake target name
# SOURCES: List of source files
# [COMPILE_DEFINITIONS]: List of private compile definitions
# [COMPILE_OPTIONS]: List of private compile options
# [LINK_LIBRARIES]: List of private libraries to use when linking
# note: ortools::ortools is always linked to the target
# [LINK_OPTIONS]: List of private link options
# e.g.:
# ortools_cxx_test(
# NAME
# foo_bar_test
# SOURCES
# bar_test.cc
# ${PROJECT_SOURCE_DIR}/ortools/foo/bar_test.cc
# LINK_LIBRARIES
# GTest::gmock
# GTest::gtest_main
# )
function(ortools_cxx_test)
set(options "DISABLED")
set(oneValueArgs "NAME")
set(multiValueArgs
"SOURCES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;LINK_LIBRARIES;LINK_OPTIONS")
cmake_parse_arguments(TEST
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
if(NOT BUILD_CXX_TESTING)
return()
endif()
if(NOT TEST_NAME)
message(FATAL_ERROR "no NAME provided")
endif()
if(NOT TEST_SOURCES)
message(FATAL_ERROR "no SOURCES provided")
endif()
message(STATUS "Configuring test ${TEST_NAME} ...")
add_executable(${TEST_NAME} "")
target_sources(${TEST_NAME} PRIVATE ${TEST_SOURCES})
target_compile_definitions(${TEST_NAME} PRIVATE ${TEST_COMPILE_DEFINITIONS})
target_compile_features(${TEST_NAME} PRIVATE cxx_std_20)
target_compile_options(${TEST_NAME} PRIVATE ${OR_TOOLS_TEST_COMPILE_OPTIONS} ${TEST_COMPILE_OPTIONS})
target_link_libraries(${TEST_NAME} PRIVATE
${PROJECT_NAMESPACE}::ortools
${PROJECT_NAMESPACE}::base_gmock
${TEST_LINK_LIBRARIES}
)
target_link_options(${TEST_NAME} PRIVATE ${TEST_LINK_OPTIONS})
include(GNUInstallDirs)
if(APPLE)
set_target_properties(${TEST_NAME} PROPERTIES
INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path")
elseif(UNIX)
cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR
BASE_DIRECTORY ${CMAKE_INSTALL_FULL_BINDIR}
OUTPUT_VARIABLE libdir_relative_path)
set_target_properties(${TEST_NAME} PROPERTIES
INSTALL_RPATH "$ORIGIN/${libdir_relative_path}:$ORIGIN")
endif()
add_test(
NAME cxx_${TEST_NAME}
COMMAND ${TEST_NAME}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
if(TEST_DISABLED)
set_tests_properties(cxx_${TEST_NAME} PROPERTIES
DISABLED TRUE
)
endif()
message(STATUS "Configuring test ${TEST_NAME} ...DONE")
endfunction()
###################
## C++ Library ##
###################
# ortools_cxx_library()
# CMake function to generate and build C++ library.
# Parameters:
# NAME: CMake target name
# SOURCES: List of source files
# [TYPE]: SHARED, STATIC or INTERFACE
# [COMPILE_DEFINITIONS]: List of **public** compile definitions
# [COMPILE_OPTIONS]: List of **public** compile options
# [LINK_LIBRARIES]: List of **public** libraries to use when linking
# [LOCAL_COMPILE_DEFINITIONS]: List of private compile definitions
# [LOCAL_COMPILE_OPTIONS]: List of private compile options
# [LOCAL_LINK_OPTIONS]: List of private link options
# [TESTING]: option flag if this library is only used to build test.
# [NO_INSTALL]: option flag to remove library from the install set
# e.g.:
# ortools_cxx_library(
# NAME
# foo_bar
# SOURCES
# bar.cc
# ${PROJECT_SOURCE_DIR}/ortools/foo/bar.cc
# TYPE
# SHARED
# COMPILE_DEFINITIONS
# OR_BUILD_DLL
# LINK_LIBRARIES
# GTest::gmock
# GTest::gtest_main
# LOCAL_COMPILE_DEFINITIONS
# OR_FOOBAR_EXPORT
# TESTING
# )
function(ortools_cxx_library)
set(options "TESTING;NO_INSTALL")
set(oneValueArgs "NAME;TYPE")
set(multiValueArgs
"SOURCES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;LINK_OPTIONS;LINK_LIBRARIES;LOCAL_COMPILE_DEFINITIONS;LOCAL_COMPILE_OPTIONS;LOCAL_LINK_OPTIONS")
cmake_parse_arguments(LIBRARY
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
if(LIBRARY_TESTING AND NOT BUILD_CXX_TESTING)
return()
endif()
if(NOT LIBRARY_NAME)
message(FATAL_ERROR "no NAME provided")
endif()
if(NOT LIBRARY_SOURCES)
message(FATAL_ERROR "no SOURCES provided")
endif()
message(STATUS "Configuring library ${LIBRARY_NAME} ...")
add_library(${LIBRARY_NAME} ${LIBRARY_TYPE} "")
set_target_properties(${LIBRARY_NAME} PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)
if(LIBRARY_TYPE STREQUAL "INTERFACE")
target_include_directories(${LIBRARY_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
target_compile_features(${LIBRARY_NAME} INTERFACE cxx_std_20)
target_compile_definitions(${LIBRARY_NAME} INTERFACE ${LIBRARY_COMPILE_DEFINITIONS})
target_compile_options(${LIBRARY_NAME} INTERFACE ${LIBRARY_COMPILE_OPTIONS})
target_link_options(${LIBRARY_NAME} INTERFACE ${LIBRARY_LINK_OPTIONS})
target_link_libraries(${LIBRARY_NAME} INTERFACE ${LIBRARY_LINK_LIBRARIES})
else()
target_include_directories(${LIBRARY_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_20)
target_compile_definitions(${LIBRARY_NAME} PUBLIC ${LIBRARY_COMPILE_DEFINITIONS})
target_compile_options(${LIBRARY_NAME} PUBLIC ${LIBRARY_COMPILE_OPTIONS})
target_link_options(${LIBRARY_NAME} PUBLIC ${LIBRARY_LINK_OPTIONS})
target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_LINK_LIBRARIES})
target_sources(${LIBRARY_NAME} PRIVATE ${LIBRARY_SOURCES})
target_compile_definitions(${LIBRARY_NAME} PRIVATE ${LIBRARY_LOCAL_COMPILE_DEFINITIONS})
target_compile_options(${LIBRARY_NAME} PRIVATE ${LIBRARY_LOCAL_COMPILE_OPTIONS})
target_link_options(${LIBRARY_NAME} PRIVATE ${LIBRARY_LOCAL_LINK_OPTIONS})
endif()
include(GNUInstallDirs)
if(APPLE)
set_target_properties(${LIBRARY_NAME} PROPERTIES
INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path"
# Apple Clang don't support version x.y.z with z > 255
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
elseif(UNIX)
cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR
BASE_DIRECTORY ${CMAKE_INSTALL_FULL_BINDIR}
OUTPUT_VARIABLE libdir_relative_path)
set_target_properties(${LIBRARY_NAME} PROPERTIES
INSTALL_RPATH "$ORIGIN/${libdir_relative_path}:$ORIGIN"
VERSION ${PROJECT_VERSION}
)
endif()
set_target_properties(${LIBRARY_NAME} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
)
if(NOT LIBRARY_NO_INSTALL)
install(TARGETS ${LIBRARY_NAME}
EXPORT ${PROJECT_NAME}Targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()
add_library(${PROJECT_NAMESPACE}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME})
message(STATUS "Configuring library ${LIBRARY_NAME} ...DONE")
endfunction()
# ortools_cxx_binary()
# CMake function to generate and build C++ library.
# Parameters:
# NAME: CMake target name
# SOURCES: List of source files
# [COMPILE_DEFINITIONS]: List of private compile definitions
# [COMPILE_OPTIONS]: List of private compile options
# [LINK_LIBRARIES]: List of private libraries to use when linking
# [LINK_OPTIONS]: List of private link options
# [TESTING]: option flag if this library is only used to build test.
# [NO_INSTALL]: option flag to remove library from the install set
# e.g.:
# ortools_cxx_binary(
# NAME
# foo_bar_binary
# SOURCES
# bar_binary.cc
# ${PROJECT_SOURCE_DIR}/ortools/foo/bar_binary.cc
# LINK_LIBRARIES
# ortools::ortools
# GTest::gmock
# GTest::gtest_main
# TESTING
# NO_INSTALL
# )
function(ortools_cxx_binary)
set(options "TESTING;NO_INSTALL")
set(oneValueArgs "NAME")
set(multiValueArgs
"SOURCES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;LINK_LIBRARIES;LINK_OPTIONS")
cmake_parse_arguments(BINARY
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
if(BINARY_TESTING AND NOT BUILD_CXX_TESTING)
return()
endif()
if(NOT BINARY_NAME)
message(FATAL_ERROR "no NAME provided")
endif()
if(NOT BINARY_SOURCES)
message(FATAL_ERROR "no SOURCES provided")
endif()
message(STATUS "Configuring binary ${BINARY_NAME} ...")
add_executable(${BINARY_NAME} ${BINARY_TYPE} "")
target_sources(${BINARY_NAME} PRIVATE ${BINARY_SOURCES})
target_compile_definitions(${BINARY_NAME} PRIVATE ${BINARY_COMPILE_DEFINITIONS})
target_compile_features(${BINARY_NAME} PRIVATE cxx_std_20)
target_compile_options(${BINARY_NAME} PRIVATE ${BINARY_COMPILE_OPTIONS})
target_link_libraries(${BINARY_NAME} PRIVATE ${BINARY_LINK_LIBRARIES})
target_link_options(${BINARY_NAME} PRIVATE ${BINARY_LINK_OPTIONS})
include(GNUInstallDirs)
if(APPLE)
set_target_properties(${BINARY_NAME} PROPERTIES
INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path")
elseif(UNIX)
cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR
BASE_DIRECTORY ${CMAKE_INSTALL_FULL_BINDIR}
OUTPUT_VARIABLE libdir_relative_path)
set_target_properties(${BINARY_NAME} PROPERTIES
INSTALL_RPATH "$ORIGIN/${libdir_relative_path}:$ORIGIN")
endif()
if(NOT BINARY_NO_INSTALL)
install(TARGETS ${BINARY_NAME}
EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()
add_executable(${PROJECT_NAMESPACE}::${BINARY_NAME} ALIAS ${BINARY_NAME})
message(STATUS "Configuring binary ${BINARY_NAME} ...DONE")
endfunction()
find_package(Python3 COMPONENTS Interpreter)
# ortools_cxx_bintest()
# CMake function to generate and build C++ test.
# Parameters:
# NAME: CMake target name
# SCRIPT: The script to run the test.
# e.g.:
# ortools_cxx_bintest(
# NAME
# foo_bar_bintest
# SCRIPT
# foo_bar.bintest
# ENVIRONMENT
# "BINTEST_foo_bar=$<TARGET_FILE:foo_bar_binary>"
# "BINTEST_foo_bar_data=$(CMAKE_CURRENT_SOURCE_DIR)/foo_bar_data.txt"
# )
function(ortools_cxx_bintest)
set(options "DISABLED")
set(oneValueArgs "NAME;SCRIPT")
set(multiValueArgs "ENVIRONMENT")
cmake_parse_arguments(BINTEST
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
if(NOT BINTEST_NAME)
message(FATAL_ERROR "no NAME provided")
endif()
if(NOT BINTEST_SCRIPT)
message(FATAL_ERROR "no SCRIPT provided")
endif()
if(NOT Python3_Interpreter_FOUND)
message(WARNING "No python3 interpreter found, the bintest ${BINTEST_NAME} is disable")
return()
endif()
message(STATUS "Configuring bintest ${BINTEST_NAME} ...")
add_test(
NAME ${BINTEST_NAME}
COMMAND ${Python3_EXECUTABLE} -m tools.testing.bintest_script_launcher ${BINTEST_SCRIPT}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
set_tests_properties(${BINTEST_NAME} PROPERTIES
ENVIRONMENT "${BINTEST_ENVIRONMENT}"
)
if(BINTEST_DISABLED)
set_tests_properties(${BINTEST_NAME} PROPERTIES
DISABLED TRUE
)
endif()
message(STATUS "Configuring bintest ${BINTEST_NAME} ...DONE")
endfunction()
##################
## PROTO FILE ##
##################
# Get Protobuf include dir
set(PROTO_DIRS)
get_target_property(protobuf_dirs protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES)
foreach(dir IN LISTS protobuf_dirs)
if (NOT "${dir}" MATCHES "INSTALL_INTERFACE|-NOTFOUND")
#message(STATUS "Adding proto path: ${dir}")
list(APPEND PROTO_DIRS "--proto_path=${dir}")
endif()
endforeach()
# Generate C++ OBJECT library from proto files,
# e.g to generate an object library ortools_foo_proto
# generate_proto_library(
# NAME
# ortools_foo
# FILES
# ortools/foo/foo.proto
# ortools/bar/bar.proto
# LINK_LIBRARIES
# ortools::ortools_core
# NO_ALIAS
# )
function(generate_proto_library)
set(options NO_ALIAS)
set(oneValueArgs NAME)
set(multiValueArgs FILES LINK_LIBRARIES)
cmake_parse_arguments(PROTO
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
if(NOT PROTO_NAME)
message(FATAL_ERROR "no NAME provided")
endif()
string(TOUPPER ${PROTO_NAME} PROTO_UPPER_NAME)
if(NOT PROTOC_PRG)
message(FATAL_ERROR "protoc binary not found.")
endif()
# Generate proto C++ files.
set(PROTO_HDRS)
set(PROTO_SRCS)
foreach(PROTO_FILE IN LISTS PROTO_FILES)
#message(STATUS "protoc proto(cc): ${PROTO_FILE}")
get_filename_component(PROTO_DIR ${PROTO_FILE} DIRECTORY)
get_filename_component(PROTO_NAME_WE ${PROTO_FILE} NAME_WE)
set(PROTO_HDR ${PROJECT_BINARY_DIR}/${PROTO_DIR}/${PROTO_NAME_WE}.pb.h)
set(PROTO_SRC ${PROJECT_BINARY_DIR}/${PROTO_DIR}/${PROTO_NAME_WE}.pb.cc)
#message(STATUS "protoc hdr: ${PROTO_HDR}")
#message(STATUS "protoc src: ${PROTO_SRC}")
add_custom_command(
OUTPUT ${PROTO_SRC} ${PROTO_HDR}
COMMAND ${PROTOC_PRG}
"--proto_path=${PROJECT_SOURCE_DIR}"
${PROTO_DIRS}
"--cpp_out=dllexport_decl=OR_${PROTO_UPPER_NAME}_PROTO_DLL:${PROJECT_BINARY_DIR}"
${PROTO_FILE}
DEPENDS ${PROTO_FILE} ${PROTOC_PRG}
COMMENT "Generate C++ protocol buffer for ${PROTO_FILE}"
VERBATIM)
list(APPEND PROTO_HDRS ${PROTO_HDR})
list(APPEND PROTO_SRCS ${PROTO_SRC})
endforeach()
# Create library
add_library(${PROTO_NAME}_proto OBJECT ${PROTO_SRCS} ${PROTO_HDRS})
target_compile_features(${PROTO_NAME}_proto PUBLIC cxx_std_20)
set_target_properties(${PROTO_NAME}_proto PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)
target_include_directories(${PROTO_NAME}_proto PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
#$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
)
target_compile_definitions(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS})
if(MSVC AND BUILD_SHARED_LIBS)
target_compile_definitions(${PROTO_NAME}_proto INTERFACE "OR_${PROTO_UPPER_NAME}_PROTO_DLL=__declspec(dllimport)")
target_compile_definitions(${PROTO_NAME}_proto PRIVATE "OR_${PROTO_UPPER_NAME}_PROTO_DLL=__declspec(dllexport)")
else()
target_compile_definitions(${PROTO_NAME}_proto PUBLIC "OR_${PROTO_UPPER_NAME}_PROTO_DLL=")
endif()
target_compile_options(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_OPTIONS})
target_link_libraries(${PROTO_NAME}_proto PUBLIC protobuf::libprotobuf ${PROTO_LINK_LIBRARIES})
add_library(${PROJECT_NAMESPACE}::${PROTO_NAME}_proto ALIAS ${PROTO_NAME}_proto)
endfunction()
# Generate Protobuf cpp sources
set(OR_TOOLS_PROTO_FILES)
if(BUILD_CORE)
file(GLOB_RECURSE CORE_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/base/*.proto"
"ortools/port/*.proto"
"ortools/util/*.proto"
"ortools/algorithms/*.proto"
"ortools/graph/*.proto"
"ortools/bop/*.proto"
"ortools/glop/*.proto"
"ortools/sat/*.proto"
"ortools/set_cover/*.proto"
"ortools/linear_solver/*.proto")
list(APPEND OR_TOOLS_PROTO_FILES ${CORE_PROTO_FILES})
endif()
if(USE_PDLP OR BUILD_MATH_OPT)
file(GLOB_RECURSE PDLP_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/pdlp/*.proto")
list(APPEND OR_TOOLS_PROTO_FILES ${PDLP_PROTO_FILES})
endif()
# ORTools proto
generate_proto_library(
NAME ortools
FILES ${OR_TOOLS_PROTO_FILES})
# Packing
if(BUILD_PACKING)
file(GLOB_RECURSE PACKING_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/packing/*.proto")
generate_proto_library(
NAME packing
FILES ${PACKING_PROTO_FILES}
LINK_LIBRARIES ${PROJECT_NAMESPACE}::ortools_proto)
endif()
# Routing proto
if(BUILD_ROUTING)
file(GLOB_RECURSE ROUTING_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/constraint_solver/*.proto"
"ortools/routing/*.proto"
"ortools/routing/parsers/*.proto")
generate_proto_library(
NAME routing
FILES ${ROUTING_PROTO_FILES}
LINK_LIBRARIES ${PROJECT_NAMESPACE}::ortools_proto)
endif()
# Scheduling
if(BUILD_SCHEDULING)
file(GLOB_RECURSE SCHEDULING_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/scheduling/*.proto")
generate_proto_library(
NAME scheduling
FILES ${SCHEDULING_PROTO_FILES}
LINK_LIBRARIES ${PROJECT_NAMESPACE}::ortools_proto)
endif()
# MathOpt proto
if(BUILD_MATH_OPT)
file(GLOB_RECURSE MATH_OPT_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/math_opt/*.proto"
"ortools/math_opt/solvers/*.proto"
)
generate_proto_library(
NAME math_opt
FILES ${MATH_OPT_PROTO_FILES}
LINK_LIBRARIES ${PROJECT_NAMESPACE}::ortools_proto)
endif()
###############
## ORTOOLS ##
###############
add_subdirectory(ortools/init)
# Main Target
ortools_cxx_library(
NAME
ortools
TYPE
SHARED
SOURCES
$<TARGET_OBJECTS:ortools_init>
COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS}
COMPILE_OPTIONS
${OR_TOOLS_COMPILE_OPTIONS}
LINK_OPTIONS
${OR_TOOLS_LINK_OPTIONS}
LINK_LIBRARIES
absl::flags
absl::strings
protobuf::libprotobuf
)
set_target_properties(ortools PROPERTIES
INTERFACE_ortools_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}
COMPATIBLE_INTERFACE_STRING ortools_MAJOR_VERSION
)
# Xcode fails to build if library doesn't contains at least one source file.
if(XCODE)
file(GENERATE
OUTPUT ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/version.cpp
CONTENT "namespace {char* version = \"${PROJECT_VERSION}\";}")
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/version.cpp)
endif()
# Generate sub library to avoid to have too many symbols
if(BUILD_CORE)
set(CORE_SRCS)
foreach(SUBPROJECT IN ITEMS base port util algorithms graph
bop glop ${PDLP_DIR} sat set_cover third_party_solvers lp_data linear_solver
)
add_subdirectory(ortools/${SUBPROJECT})
list(APPEND CORE_SRCS $<TARGET_OBJECTS:ortools_${SUBPROJECT}>)
endforeach()
if(USE_GLPK)
add_subdirectory(ortools/third_party_solvers/glpk)
list(APPEND CORE_SRCS $<TARGET_OBJECTS:ortools_glpk>)
endif()
add_subdirectory(ortools/linear_solver/wrappers)
list(APPEND CORE_SRCS $<TARGET_OBJECTS:ortools_linear_solver_wrappers>)
add_subdirectory(ortools/linear_solver/proto_solver)
list(APPEND CORE_SRCS $<TARGET_OBJECTS:ortools_linear_solver_proto_solver>)
ortools_cxx_library(
NAME
ortools_core
TYPE
SHARED
SOURCES
${CORE_SRCS}
$<TARGET_OBJECTS:ortools_proto>
COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS}
COMPILE_OPTIONS
${OR_TOOLS_COMPILE_OPTIONS}
LOCAL_COMPILE_DEFINITIONS
OR_EXPORT
LINK_LIBRARIES
${CMAKE_DL_LIBS}
ZLIB::ZLIB
BZip2::BZip2
${ABSL_DEPS}
protobuf::libprotobuf
${RE2_DEPS}
${COINOR_DEPS}
${CPLEX_DEPS}
${GLPK_DEPS}
${HIGHS_DEPS}
${PDLP_DEPS}
${SCIP_DEPS}
Threads::Threads
)
if(WIN32)
target_link_libraries(ortools_core PUBLIC psapi.lib ws2_32.lib)
endif()
if(XCODE)
file(GENERATE
OUTPUT ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/core_version.cpp
CONTENT "namespace {char* core_version = \"${PROJECT_VERSION}\";}")
target_sources(ortools_core PRIVATE
${PROJECT_BINARY_DIR}/${PROJECT_NAME}/core_version.cpp)
endif()
if(MSVC AND BUILD_SHARED_LIBS)
target_compile_definitions(ortools_core PUBLIC "OR_ORTOOLS_PROTO_DLL=__declspec(dllimport)")
else()
target_compile_definitions(ortools_core PUBLIC "OR_ORTOOLS_PROTO_DLL=")
endif()
target_link_libraries(ortools PUBLIC ortools_core)
endif()
if(BUILD_MATH_OPT)
add_subdirectory(ortools/gurobi)
add_subdirectory(ortools/math_opt)
if(XCODE)
file(GENERATE
OUTPUT ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/math_opt_version.cpp
CONTENT "namespace {char* math_opt_version = \"${PROJECT_VERSION}\";}")
target_sources(ortools_math_opt PRIVATE
${PROJECT_BINARY_DIR}/${PROJECT_NAME}/math_opt_version.cpp)
endif()
target_link_libraries(ortools PUBLIC ortools_math_opt)
endif()
if(BUILD_PACKING)
add_subdirectory(ortools/packing)
target_link_libraries(ortools PUBLIC ortools_packing)
endif()
if(BUILD_ROUTING)
add_subdirectory(ortools/constraint_solver)
add_subdirectory(ortools/routing)
add_subdirectory(ortools/routing/parsers)
ortools_cxx_library(
NAME
ortools_routing
TYPE
SHARED
SOURCES
$<TARGET_OBJECTS:routing_proto>
$<TARGET_OBJECTS:ortools_constraint_solver>
$<TARGET_OBJECTS:ortools_routing_solver>
$<TARGET_OBJECTS:ortools_routing_parsers>
COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS}
COMPILE_OPTIONS
${OR_TOOLS_COMPILE_OPTIONS}
LINK_LIBRARIES
ortools::ortools_core
)
if(MSVC AND BUILD_SHARED_LIBS)
target_compile_definitions(ortools_routing PUBLIC "OR_ROUTING_PROTO_DLL=__declspec(dllimport)")
else()
target_compile_definitions(ortools_routing PUBLIC "OR_ROUTING_PROTO_DLL=")
endif()
if(XCODE)
file(GENERATE
OUTPUT ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/routing_version.cpp
CONTENT "namespace {char* routing_version = \"${PROJECT_VERSION}\";}")
target_sources(ortools_routing PRIVATE
${PROJECT_BINARY_DIR}/${PROJECT_NAME}/routing_version.cpp)
endif()
target_link_libraries(ortools PUBLIC ortools_routing)
endif()
if(BUILD_SCHEDULING)
add_subdirectory(ortools/scheduling)
target_link_libraries(ortools PUBLIC ortools_scheduling)
endif()
###############
## Doc rules ##
###############
if(BUILD_CXX_DOC)
# add a target to generate API documentation with Doxygen
find_package(Doxygen REQUIRED)
if(DOXYGEN_FOUND)
configure_file(
${PROJECT_SOURCE_DIR}/ortools/cpp/Doxyfile.in
${PROJECT_BINARY_DIR}/cpp/Doxyfile
@ONLY)
configure_file(
${PROJECT_SOURCE_DIR}/ortools/cpp/dirs.cpp.dox.in
${PROJECT_BINARY_DIR}/ortools/dirs.cpp.dox
@ONLY)
configure_file(
${PROJECT_SOURCE_DIR}/ortools/cpp/main.cpp.dox.in
${PROJECT_BINARY_DIR}/ortools/main.cpp.dox
@ONLY)
file(DOWNLOAD
https://raw.githubusercontent.com/jothepro/doxygen-awesome-css/v2.3.4/doxygen-awesome.css
${PROJECT_BINARY_DIR}/cpp/doxygen-awesome.css
SHOW_PROGRESS
)
add_custom_target(${PROJECT_NAME}_cxx_doc ALL
#COMMAND ${CMAKE_COMMAND} -E rm -rf ${PROJECT_BINARY_DIR}/docs/cpp
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/docs/cpp
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/cpp/Doxyfile
DEPENDS
${PROJECT_NAMESPACE}::ortools
${PROJECT_BINARY_DIR}/cpp/Doxyfile
${PROJECT_BINARY_DIR}/cpp/doxygen-awesome.css
${PROJECT_SOURCE_DIR}/ortools/doxygen/header.html
${PROJECT_SOURCE_DIR}/ortools/doxygen/DoxygenLayout.xml
${PROJECT_SOURCE_DIR}/ortools/cpp/stylesheet.css
${PROJECT_BINARY_DIR}/ortools/main.cpp.dox
${PROJECT_BINARY_DIR}/ortools/dirs.cpp.dox
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generating C++ API documentation with Doxygen"
VERBATIM)
else()
message(WARNING "cmd `doxygen` not found, C++ doc generation is disable!")
endif()
endif()
###################
## Install rules ##
###################
include(GNUInstallDirs)
include(GenerateExportHeader)
GENERATE_EXPORT_HEADER(${PROJECT_NAME})
install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}_export.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAMESPACE}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT Devel)
install(DIRECTORY ortools
TYPE INCLUDE
COMPONENT Devel
FILES_MATCHING
PATTERN "*.h")
install(DIRECTORY ${PROJECT_BINARY_DIR}/ortools
TYPE INCLUDE
COMPONENT Devel
FILES_MATCHING
PATTERN "*.pb.h"
PATTERN CMakeFiles EXCLUDE)
include(CMakePackageConfigHelpers)
string (TOUPPER "${PROJECT_NAME}" PACKAGE_PREFIX)
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion)
install(
FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT Devel)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/Findre2.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
if(USE_COINOR)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/FindCbc.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindClp.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(USE_GLPK)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/FindGLPK.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(USE_PDLP)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/FindEigen3.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(USE_SCIP)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/FindSCIP.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
install(FILES "${PROJECT_SOURCE_DIR}/LICENSE"
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
COMPONENT Devel)
if(INSTALL_DOC)
install(DIRECTORY ortools/sat/docs/
DESTINATION "${CMAKE_INSTALL_DOCDIR}/sat"
FILES_MATCHING
PATTERN "*.md")
install(DIRECTORY ortools/constraint_solver/docs/
DESTINATION "${CMAKE_INSTALL_DOCDIR}/constraint_solver"
FILES_MATCHING
PATTERN "*.md")
install(DIRECTORY ortools/routing/docs/
DESTINATION "${CMAKE_INSTALL_DOCDIR}/routing"
FILES_MATCHING
PATTERN "*.md")
endif()
##################
## C++ Sample ##
##################
# add_cxx_sample()
# CMake function to generate and build C++ sample.
# Parameters:
# FILE_NAME: the C++ filename
# COMPONENT_NAME: name of the ortools/ subdir where the test is located
# note: automatically determined if located in ortools/<component>/samples/
# e.g.:
# add_cxx_sample(
# FILE_NAME
# ${PROJECT_SOURCE_DIR}/ortools/foo/sample/bar.cc
# COMPONENT_NAME
# foo
# )