diff --git a/cmake/dotnet.cmake b/cmake/dotnet.cmake index 51b88a98f8..e1bd435dd1 100644 --- a/cmake/dotnet.cmake +++ b/cmake/dotnet.cmake @@ -186,67 +186,91 @@ endif() ################# ## .Net Test ## ################# -if(BUILD_TESTING) - # add_dotnet_test() - # CMake function to generate and build dotnet test. - # Parameters: - # the dotnet filename - # e.g.: - # add_dotnet_test(FooTests.cs) - function(add_dotnet_test FILE_NAME) - message(STATUS "Configuring test ${FILE_NAME} ...") - get_filename_component(TEST_NAME ${FILE_NAME} NAME_WE) - get_filename_component(WRAPPER_DIR ${FILE_NAME} DIRECTORY) +# add_dotnet_test() +# CMake function to generate and build dotnet test. +# Parameters: +# FILE_NAME: the .Net filename +# COMPONENT_NAME: name of the ortools/ subdir where the test is located +# note: automatically determined if located in ortools//dotnet/ +# e.g.: +# add_dotnet_test( +# FILE_NAME +# ${PROJECT_SOURCE_DIR}/ortools/foo/dotnet/BarTests.cs +# COMPONENT_NAME +# foo +# ) +function(add_dotnet_test) + set(options "") + set(oneValueArgs FILE_NAME COMPONENT_NAME) + set(multiValueArgs "") + cmake_parse_arguments(TEST + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) + if(NOT TEST_FILE_NAME) + message(FATAL_ERROR "no FILE_NAME provided") + endif() + get_filename_component(TEST_NAME ${TEST_FILE_NAME} NAME_WE) + + message(STATUS "Configuring test ${TEST_FILE_NAME} ...") + + if(NOT TEST_COMPONENT_NAME) + # test is located in ortools//dotnet/ + get_filename_component(WRAPPER_DIR ${TEST_FILE_NAME} DIRECTORY) get_filename_component(COMPONENT_DIR ${WRAPPER_DIR} DIRECTORY) get_filename_component(COMPONENT_NAME ${COMPONENT_DIR} NAME) + else() + set(COMPONENT_NAME ${TEST_COMPONENT_NAME}) + endif() - set(DOTNET_TEST_DIR ${PROJECT_BINARY_DIR}/dotnet/${COMPONENT_NAME}/${TEST_NAME}) - message(STATUS "build path: ${DOTNET_TEST_DIR}") + set(DOTNET_TEST_DIR ${PROJECT_BINARY_DIR}/dotnet/${COMPONENT_NAME}/${TEST_NAME}) + message(STATUS "build path: ${DOTNET_TEST_DIR}") - configure_file( - ${PROJECT_SOURCE_DIR}/ortools/dotnet/Test.csproj.in - ${DOTNET_TEST_DIR}/${TEST_NAME}.csproj - @ONLY) + configure_file( + ${PROJECT_SOURCE_DIR}/ortools/dotnet/Test.csproj.in + ${DOTNET_TEST_DIR}/${TEST_NAME}.csproj + @ONLY) - add_custom_command( - OUTPUT ${DOTNET_TEST_DIR}/${TEST_NAME}.cs - COMMAND ${CMAKE_COMMAND} -E make_directory ${DOTNET_TEST_DIR} - COMMAND ${CMAKE_COMMAND} -E copy - ${FILE_NAME} - ${DOTNET_TEST_DIR}/ - MAIN_DEPENDENCY ${FILE_NAME} - VERBATIM - WORKING_DIRECTORY ${DOTNET_TEST_DIR}) + add_custom_command( + OUTPUT ${DOTNET_TEST_DIR}/${TEST_NAME}.cs + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOTNET_TEST_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${TEST_FILE_NAME} ${DOTNET_TEST_DIR}/ + MAIN_DEPENDENCY ${TEST_FILE_NAME} + VERBATIM + WORKING_DIRECTORY ${DOTNET_TEST_DIR}) - add_custom_command( - OUTPUT ${DOTNET_TEST_DIR}/timestamp - COMMAND ${CMAKE_COMMAND} -E env --unset=TARGETNAME - ${DOTNET_EXECUTABLE} build --nologo -c Release ${TEST_NAME}.csproj - COMMAND ${CMAKE_COMMAND} -E touch ${DOTNET_TEST_DIR}/timestamp - DEPENDS - ${DOTNET_TEST_DIR}/${TEST_NAME}.csproj - ${DOTNET_TEST_DIR}/${TEST_NAME}.cs - dotnet_package - BYPRODUCTS - ${DOTNET_TEST_DIR}/bin - ${DOTNET_TEST_DIR}/obj - VERBATIM - COMMENT "Compiling .Net ${COMPONENT_NAME}/${TEST_NAME}.cs (${DOTNET_TEST_DIR}/timestamp)" - WORKING_DIRECTORY ${DOTNET_TEST_DIR}) + add_custom_command( + OUTPUT ${DOTNET_TEST_DIR}/timestamp + COMMAND ${CMAKE_COMMAND} -E env --unset=TARGETNAME + ${DOTNET_EXECUTABLE} build --nologo -c Release ${TEST_NAME}.csproj + COMMAND ${CMAKE_COMMAND} -E touch ${DOTNET_TEST_DIR}/timestamp + DEPENDS + ${DOTNET_TEST_DIR}/${TEST_NAME}.csproj + ${DOTNET_TEST_DIR}/${TEST_NAME}.cs + dotnet_package + BYPRODUCTS + ${DOTNET_TEST_DIR}/bin + ${DOTNET_TEST_DIR}/obj + VERBATIM + COMMENT "Compiling .Net ${COMPONENT_NAME}/${TEST_NAME}.cs (${DOTNET_TEST_DIR}/timestamp)" + WORKING_DIRECTORY ${DOTNET_TEST_DIR}) - add_custom_target(dotnet_${COMPONENT_NAME}_${TEST_NAME} ALL - DEPENDS - ${DOTNET_TEST_DIR}/timestamp - WORKING_DIRECTORY ${DOTNET_TEST_DIR}) + add_custom_target(dotnet_${COMPONENT_NAME}_${TEST_NAME} ALL + DEPENDS + ${DOTNET_TEST_DIR}/timestamp + WORKING_DIRECTORY ${DOTNET_TEST_DIR}) + if(BUILD_TESTING) add_test( NAME dotnet_${COMPONENT_NAME}_${TEST_NAME} COMMAND ${CMAKE_COMMAND} -E env --unset=TARGETNAME - ${DOTNET_EXECUTABLE} test --nologo -c Release ${TEST_NAME}.csproj + ${DOTNET_EXECUTABLE} test --nologo -c Release ${TEST_NAME}.csproj WORKING_DIRECTORY ${DOTNET_TEST_DIR}) - message(STATUS "Configuring test ${FILE_NAME} done") - endfunction() -endif() + endif() + message(STATUS "Configuring test ${TEST_FILE_NAME} ...DONE") +endfunction() ####################### ## DOTNET WRAPPERS ## @@ -429,15 +453,41 @@ endif() # add_dotnet_sample() # CMake function to generate and build dotnet sample. # Parameters: -# the dotnet filename +# FILE_NAME: the .Net filename +# COMPONENT_NAME: name of the ortools/ subdir where the test is located +# note: automatically determined if located in ortools//samples/ # e.g.: -# add_dotnet_sample(FooApp.cs) -function(add_dotnet_sample FILE_NAME) - message(STATUS "Configuring sample ${FILE_NAME} ...") - get_filename_component(SAMPLE_NAME ${FILE_NAME} NAME_WE) - get_filename_component(SAMPLE_DIR ${FILE_NAME} DIRECTORY) - get_filename_component(COMPONENT_DIR ${SAMPLE_DIR} DIRECTORY) - get_filename_component(COMPONENT_NAME ${COMPONENT_DIR} NAME) +# add_dotnet_sample( +# FILE_NAME +# ${PROJECT_SOURCE_DIR}/ortools/foo/sample/Bar.cs +# COMPONENT_NAME +# foo +# ) +function(add_dotnet_sample) + set(options "") + set(oneValueArgs FILE_NAME COMPONENT_NAME) + set(multiValueArgs "") + cmake_parse_arguments(SAMPLE + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) + if(NOT SAMPLE_FILE_NAME) + message(FATAL_ERROR "no FILE_NAME provided") + endif() + get_filename_component(SAMPLE_NAME ${SAMPLE_FILE_NAME} NAME_WE) + + message(STATUS "Configuring sample ${SAMPLE_FILE_NAME} ...") + + if(NOT SAMPLE_COMPONENT_NAME) + # sample is located in ortools//sample/ + get_filename_component(SAMPLE_DIR ${SAMPLE_FILE_NAME} DIRECTORY) + get_filename_component(COMPONENT_DIR ${SAMPLE_DIR} DIRECTORY) + get_filename_component(COMPONENT_NAME ${COMPONENT_DIR} NAME) + else() + set(COMPONENT_NAME ${SAMPLE_COMPONENT_NAME}) + endif() set(DOTNET_SAMPLE_DIR ${PROJECT_BINARY_DIR}/dotnet/${COMPONENT_NAME}/${SAMPLE_NAME}) message(STATUS "build path: ${DOTNET_SAMPLE_DIR}") @@ -450,10 +500,8 @@ function(add_dotnet_sample FILE_NAME) add_custom_command( OUTPUT ${DOTNET_SAMPLE_DIR}/${SAMPLE_NAME}.cs COMMAND ${CMAKE_COMMAND} -E make_directory ${DOTNET_SAMPLE_DIR} - COMMAND ${CMAKE_COMMAND} -E copy - ${FILE_NAME} - ${DOTNET_SAMPLE_DIR}/ - MAIN_DEPENDENCY ${FILE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy ${SAMPLE_FILE_NAME} ${DOTNET_SAMPLE_DIR}/ + MAIN_DEPENDENCY ${SAMPLE_FILE_NAME} VERBATIM WORKING_DIRECTORY ${DOTNET_SAMPLE_DIR}) @@ -509,7 +557,7 @@ function(add_dotnet_sample FILE_NAME) WORKING_DIRECTORY ${DOTNET_SAMPLE_DIR}) endif() endif() - message(STATUS "Configuring sample ${FILE_NAME} done") + message(STATUS "Configuring sample ${SAMPLE_FILE_NAME} ...DONE") endfunction() #################### @@ -518,31 +566,55 @@ endfunction() # add_dotnet_example() # CMake function to generate and build dotnet example. # Parameters: -# the dotnet filename +# FILE_NAME: the .Net filename +# COMPONENT_NAME: name of the example/ subdir where the test is located +# note: automatically determined if located in examples// # e.g.: -# add_dotnet_example(Foo.cs) -function(add_dotnet_example FILE_NAME) - message(STATUS "Configuring example ${FILE_NAME} ...") - get_filename_component(EXAMPLE_NAME ${FILE_NAME} NAME_WE) - get_filename_component(COMPONENT_DIR ${FILE_NAME} DIRECTORY) - get_filename_component(COMPONENT_NAME ${COMPONENT_DIR} NAME) +# add_dotnet_example( +# FILE_NAME +# ${PROJECT_SOURCE_DIR}/examples/foo/Bar.cs +# COMPONENT_NAME +# foo +# ) +function(add_dotnet_example) + set(options "") + set(oneValueArgs FILE_NAME COMPONENT_NAME) + set(multiValueArgs "") + cmake_parse_arguments(EXAMPLE + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) +if(NOT EXAMPLE_FILE_NAME) + message(FATAL_ERROR "no FILE_NAME provided") + endif() + get_filename_component(EXAMPLE_NAME ${EXAMPLE_FILE_NAME} NAME_WE) + + message(STATUS "Configuring example ${EXAMPLE_FILE_NAME} ...") + + if(NOT EXAMPLE_COMPONENT_NAME) + # sample is located in examples// + get_filename_component(COMPONENT_DIR ${EXAMPLE_FILE_NAME} DIRECTORY) + get_filename_component(COMPONENT_NAME ${COMPONENT_DIR} NAME) + else() + set(COMPONENT_NAME ${EXAMPLE_COMPONENT_NAME}) + endif() set(DOTNET_EXAMPLE_DIR ${PROJECT_BINARY_DIR}/dotnet/${COMPONENT_NAME}/${EXAMPLE_NAME}) message(STATUS "build path: ${DOTNET_EXAMPLE_DIR}") set(SAMPLE_NAME ${EXAMPLE_NAME}) configure_file( - ${PROJECT_SOURCE_DIR}/ortools/dotnet/Sample.csproj.in + ${PROJECT_SOURCE_DIR}/ortools/dotnet/Example.csproj.in ${DOTNET_EXAMPLE_DIR}/${EXAMPLE_NAME}.csproj @ONLY) add_custom_command( OUTPUT ${DOTNET_EXAMPLE_DIR}/${EXAMPLE_NAME}.cs COMMAND ${CMAKE_COMMAND} -E make_directory ${DOTNET_EXAMPLE_DIR} - COMMAND ${CMAKE_COMMAND} -E copy - ${FILE_NAME} - ${DOTNET_EXAMPLE_DIR}/ - MAIN_DEPENDENCY ${FILE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy ${EXAMPLE_FILE_NAME} ${DOTNET_EXAMPLE_DIR}/ + MAIN_DEPENDENCY ${EXAMPLE_FILE_NAME} VERBATIM WORKING_DIRECTORY ${DOTNET_EXAMPLE_DIR}) @@ -598,5 +670,5 @@ function(add_dotnet_example FILE_NAME) WORKING_DIRECTORY ${DOTNET_EXAMPLE_DIR}) endif() endif() - message(STATUS "Configuring example ${FILE_NAME} done") + message(STATUS "Configuring example ${EXAMPLE_FILE_NAME} ...DONE") endfunction() diff --git a/examples/contrib/CMakeLists.txt b/examples/contrib/CMakeLists.txt index 4915e2e431..c214812288 100644 --- a/examples/contrib/CMakeLists.txt +++ b/examples/contrib/CMakeLists.txt @@ -57,6 +57,6 @@ if(BUILD_DOTNET_EXAMPLES) # Not working everywhere since it rely on /usr/share/dict/words list(FILTER DOTNET_SRCS EXCLUDE REGEX ".*/word_square.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_example(${FILE_NAME}) + add_dotnet_example(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/examples/dotnet/CMakeLists.txt b/examples/dotnet/CMakeLists.txt index 37d7151fd6..7f80138871 100644 --- a/examples/dotnet/CMakeLists.txt +++ b/examples/dotnet/CMakeLists.txt @@ -17,5 +17,5 @@ endif() file(GLOB DOTNET_SRCS "*.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_example(${FILE_NAME}) + add_dotnet_example(FILE_NAME ${FILE_NAME}) endforeach() diff --git a/examples/tests/CMakeLists.txt b/examples/tests/CMakeLists.txt index 5547a97b3c..dde08ddf45 100644 --- a/examples/tests/CMakeLists.txt +++ b/examples/tests/CMakeLists.txt @@ -39,6 +39,6 @@ endif() if(BUILD_DOTNET_EXAMPLES) file(GLOB DOTNET_SRCS "*.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_example(${FILE_NAME}) + add_dotnet_example(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/ortools/algorithms/csharp/CMakeLists.txt b/ortools/algorithms/csharp/CMakeLists.txt index e8e5cc2c59..a8012781ac 100644 --- a/ortools/algorithms/csharp/CMakeLists.txt +++ b/ortools/algorithms/csharp/CMakeLists.txt @@ -33,6 +33,6 @@ target_link_libraries(dotnet_algorithms PRIVATE ortools::ortools) if(BUILD_TESTING) file(GLOB DOTNET_SRCS "*Tests.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_test(${FILE_NAME}) + add_dotnet_test(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/ortools/algorithms/samples/CMakeLists.txt b/ortools/algorithms/samples/CMakeLists.txt index d7e1735ef5..95ad292dd6 100644 --- a/ortools/algorithms/samples/CMakeLists.txt +++ b/ortools/algorithms/samples/CMakeLists.txt @@ -39,6 +39,6 @@ endif() if(BUILD_DOTNET_SAMPLES) file(GLOB DOTNET_SRCS "*.cs") foreach(SAMPLE IN LISTS DOTNET_SRCS) - add_dotnet_sample(${SAMPLE}) + add_dotnet_sample(FILE_NAME ${SAMPLE}) endforeach() endif() diff --git a/ortools/constraint_solver/csharp/CMakeLists.txt b/ortools/constraint_solver/csharp/CMakeLists.txt index 6c7e6c82a6..4a1a83a6e5 100644 --- a/ortools/constraint_solver/csharp/CMakeLists.txt +++ b/ortools/constraint_solver/csharp/CMakeLists.txt @@ -33,6 +33,6 @@ target_link_libraries(dotnet_constraint_solver PRIVATE ortools::ortools) if(BUILD_TESTING) file(GLOB DOTNET_SRCS "*Tests.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_test(${FILE_NAME}) + add_dotnet_test(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/ortools/constraint_solver/samples/CMakeLists.txt b/ortools/constraint_solver/samples/CMakeLists.txt index d7e1735ef5..95ad292dd6 100644 --- a/ortools/constraint_solver/samples/CMakeLists.txt +++ b/ortools/constraint_solver/samples/CMakeLists.txt @@ -39,6 +39,6 @@ endif() if(BUILD_DOTNET_SAMPLES) file(GLOB DOTNET_SRCS "*.cs") foreach(SAMPLE IN LISTS DOTNET_SRCS) - add_dotnet_sample(${SAMPLE}) + add_dotnet_sample(FILE_NAME ${SAMPLE}) endforeach() endif() diff --git a/ortools/dotnet/Example.csproj.in b/ortools/dotnet/Example.csproj.in new file mode 100644 index 0000000000..b48df75b3c --- /dev/null +++ b/ortools/dotnet/Example.csproj.in @@ -0,0 +1,48 @@ + + + Exe + @DOTNET_SAMPLE_LANG@ + @DOTNET_TFM@ + false + false + + LatestMajor + true + @DOTNET_PROJECT@.@COMPONENT_NAME@.@EXAMPLE_NAME@ + @PROJECT_VERSION@ + + + Simple App consuming @DOTNET_PROJECT@ package + + + true + @DOTNET_PROJECT@.@COMPONENT_NAME@.@EXAMPLE_NAME@ v@PROJECT_VERSION@ + @DOTNET_PROJECT@.@COMPONENT_NAME@.@EXAMPLE_NAME@ + sample + true + snupkg + @DOTNET_PACKAGES_DIR@/samples + + + false + false + false + + + + full + true + true + + + + + @DOTNET_PACKAGES_DIR@;$(RestoreSources);https://api.nuget.org/v3/index.json + + + + + + + + diff --git a/ortools/dotnet/Sample.csproj.in b/ortools/dotnet/Sample.csproj.in index 3d9802fa5c..9b28387357 100644 --- a/ortools/dotnet/Sample.csproj.in +++ b/ortools/dotnet/Sample.csproj.in @@ -8,7 +8,7 @@ LatestMajor true - @DOTNET_PROJECT@.@SAMPLE_NAME@ + @DOTNET_PROJECT@.@COMPONENT_NAME@.@SAMPLE_NAME@ @PROJECT_VERSION@ @@ -16,8 +16,8 @@ true - @DOTNET_PROJECT@.@SAMPLE_NAME@ v@PROJECT_VERSION@ - @DOTNET_PROJECT@.@SAMPLE_NAME@ + @DOTNET_PROJECT@.@COMPONENT_NAME@.@SAMPLE_NAME@ v@PROJECT_VERSION@ + @DOTNET_PROJECT@.@COMPONENT_NAME@.@SAMPLE_NAME@ sample true snupkg @@ -41,7 +41,7 @@ - + diff --git a/ortools/dotnet/Test.csproj.in b/ortools/dotnet/Test.csproj.in index 2ff14fb260..f10a2c90b4 100644 --- a/ortools/dotnet/Test.csproj.in +++ b/ortools/dotnet/Test.csproj.in @@ -32,7 +32,7 @@ - + diff --git a/ortools/graph/csharp/CMakeLists.txt b/ortools/graph/csharp/CMakeLists.txt index 536b8068f1..c891550a88 100644 --- a/ortools/graph/csharp/CMakeLists.txt +++ b/ortools/graph/csharp/CMakeLists.txt @@ -33,6 +33,6 @@ target_link_libraries(dotnet_graph PRIVATE ortools::ortools) if(BUILD_TESTING) file(GLOB DOTNET_SRCS "*Tests.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_test(${FILE_NAME}) + add_dotnet_test(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/ortools/graph/samples/CMakeLists.txt b/ortools/graph/samples/CMakeLists.txt index d7e1735ef5..95ad292dd6 100644 --- a/ortools/graph/samples/CMakeLists.txt +++ b/ortools/graph/samples/CMakeLists.txt @@ -39,6 +39,6 @@ endif() if(BUILD_DOTNET_SAMPLES) file(GLOB DOTNET_SRCS "*.cs") foreach(SAMPLE IN LISTS DOTNET_SRCS) - add_dotnet_sample(${SAMPLE}) + add_dotnet_sample(FILE_NAME ${SAMPLE}) endforeach() endif() diff --git a/ortools/init/csharp/CMakeLists.txt b/ortools/init/csharp/CMakeLists.txt index ce474e9748..130eb2b802 100644 --- a/ortools/init/csharp/CMakeLists.txt +++ b/ortools/init/csharp/CMakeLists.txt @@ -33,6 +33,6 @@ target_link_libraries(dotnet_init PRIVATE ortools::ortools) if(BUILD_TESTING) file(GLOB DOTNET_SRCS "*Tests.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_test(${FILE_NAME}) + add_dotnet_test(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/ortools/linear_solver/csharp/CMakeLists.txt b/ortools/linear_solver/csharp/CMakeLists.txt index 4e164274af..9189c280b4 100644 --- a/ortools/linear_solver/csharp/CMakeLists.txt +++ b/ortools/linear_solver/csharp/CMakeLists.txt @@ -52,6 +52,6 @@ target_link_libraries(dotnet_model_builder PRIVATE ortools::ortools) if(BUILD_TESTING) file(GLOB DOTNET_SRCS "*Tests.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_test(${FILE_NAME}) + add_dotnet_test(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/ortools/linear_solver/samples/CMakeLists.txt b/ortools/linear_solver/samples/CMakeLists.txt index d7e1735ef5..95ad292dd6 100644 --- a/ortools/linear_solver/samples/CMakeLists.txt +++ b/ortools/linear_solver/samples/CMakeLists.txt @@ -39,6 +39,6 @@ endif() if(BUILD_DOTNET_SAMPLES) file(GLOB DOTNET_SRCS "*.cs") foreach(SAMPLE IN LISTS DOTNET_SRCS) - add_dotnet_sample(${SAMPLE}) + add_dotnet_sample(FILE_NAME ${SAMPLE}) endforeach() endif() diff --git a/ortools/sat/csharp/CMakeLists.txt b/ortools/sat/csharp/CMakeLists.txt index 6b398645c4..6a9856b374 100644 --- a/ortools/sat/csharp/CMakeLists.txt +++ b/ortools/sat/csharp/CMakeLists.txt @@ -33,6 +33,6 @@ target_link_libraries(dotnet_sat PRIVATE ortools::ortools) if(BUILD_TESTING) file(GLOB DOTNET_SRCS "*Tests.cs") foreach(FILE_NAME IN LISTS DOTNET_SRCS) - add_dotnet_test(${FILE_NAME}) + add_dotnet_test(FILE_NAME ${FILE_NAME}) endforeach() endif() diff --git a/ortools/sat/samples/CMakeLists.txt b/ortools/sat/samples/CMakeLists.txt index d7e1735ef5..95ad292dd6 100644 --- a/ortools/sat/samples/CMakeLists.txt +++ b/ortools/sat/samples/CMakeLists.txt @@ -39,6 +39,6 @@ endif() if(BUILD_DOTNET_SAMPLES) file(GLOB DOTNET_SRCS "*.cs") foreach(SAMPLE IN LISTS DOTNET_SRCS) - add_dotnet_sample(${SAMPLE}) + add_dotnet_sample(FILE_NAME ${SAMPLE}) endforeach() endif()