Skip to content
34 changes: 32 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ project(
LANGUAGES CXX CUDA C
)

# Disable C++20 module scanning as the codebase doesn't use modules
set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning")

Comment on lines +32 to +34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Be explicit about whether you want to override user cache values for module scanning.

set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL ...) won’t change an existing cache value, so module scanning could remain enabled for targets that don’t explicitly set CXX_SCAN_FOR_MODULES OFF. If the intent is “always disable”, consider FORCE; if the intent is “default off, but user can opt in”, consider guarding with if(NOT DEFINED ...) to make that intent clear.

Proposed tweak (pick one)
-# Disable C++20 module scanning as the codebase doesn't use modules
-set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning")
+# Disable C++20 module scanning as the codebase doesn't use modules
+# Option A: default-off (user can override via -D...)
+if(NOT DEFINED CMAKE_CXX_SCAN_FOR_MODULES)
+  set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning")
+endif()
+
+# Option B: always-off (override any existing cache)
+# set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning" FORCE)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Disable C++20 module scanning as the codebase doesn't use modules
set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning")
# Disable C++20 module scanning as the codebase doesn't use modules
# Option A: default-off (user can override via -D...)
if(NOT DEFINED CMAKE_CXX_SCAN_FOR_MODULES)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning")
endif()
# Option B: always-off (override any existing cache)
# set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning" FORCE)
🤖 Prompt for AI Agents
In @cpp/CMakeLists.txt around lines 32 - 34, The CMake cache variable
CMAKE_CXX_SCAN_FOR_MODULES is being set without clarifying whether you intend to
override an existing user cache value; change the directive to explicitly
express intent: if you always want to disable module scanning, replace the
current set(...) with set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable
C++20 module scanning" FORCE), otherwise make it a user-default by guarding with
if(NOT DEFINED CMAKE_CXX_SCAN_FOR_MODULES) before calling
set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning")
so users can opt in.

rapids_cmake_write_version_file(include/cuopt/version_config.hpp)
# ##################################################################################################
# - build type ------------------------------------------------------------------------------------
Expand Down Expand Up @@ -243,11 +246,12 @@ set_target_properties(cuopt
INSTALL_RPATH "\$ORIGIN"

# set target compile options
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD 20
CUDA_STANDARD_REQUIRED ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
CXX_SCAN_FOR_MODULES OFF
)

target_compile_definitions(cuopt PUBLIC "CUOPT_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${LIBCUOPT_LOGGING_LEVEL}")
Expand Down Expand Up @@ -446,6 +450,14 @@ endif()

if(NOT BUILD_LP_ONLY)
add_executable(cuopt_cli cuopt_cli.cpp)

set_target_properties(cuopt_cli
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_SCAN_FOR_MODULES OFF
)

target_compile_options(cuopt_cli
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
Expand Down Expand Up @@ -486,6 +498,14 @@ endif()
option(BUILD_MIP_BENCHMARKS "Build MIP benchmarks" OFF)
if(BUILD_MIP_BENCHMARKS AND NOT BUILD_LP_ONLY)
add_executable(solve_MIP ../benchmarks/linear_programming/cuopt/run_mip.cpp)

set_target_properties(solve_MIP
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_SCAN_FOR_MODULES OFF
)

target_compile_options(solve_MIP
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
Expand All @@ -510,6 +530,16 @@ endif()
option(BUILD_LP_BENCHMARKS "Build LP benchmarks" OFF)
if(BUILD_LP_BENCHMARKS)
add_executable(solve_LP ../benchmarks/linear_programming/cuopt/run_pdlp.cu)

set_target_properties(solve_LP
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 20
CUDA_STANDARD_REQUIRED ON
CXX_SCAN_FOR_MODULES OFF
)

target_compile_options(solve_LP
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
Expand Down
8 changes: 6 additions & 2 deletions cpp/libmps_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cmake-format: off
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on

Expand All @@ -16,6 +16,9 @@ project(
LANGUAGES CXX
)

# Disable C++20 module scanning as the codebase doesn't use modules
set(CMAKE_CXX_SCAN_FOR_MODULES OFF CACHE BOOL "Disable C++20 module scanning")

# Write the version header
rapids_cmake_write_version_file(include/mps_parser/version_config.hpp)

Expand Down Expand Up @@ -79,9 +82,10 @@ set_target_properties(mps_parser
INSTALL_RPATH "\$ORIGIN"

# set target compile options
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
CXX_SCAN_FOR_MODULES OFF
)

target_compile_options(mps_parser
Expand Down
5 changes: 3 additions & 2 deletions cpp/libmps_parser/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cmake-format: off
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on

Expand All @@ -13,9 +13,10 @@ function(ConfigureTest CMAKE_TEST_NAME)
set_target_properties(${CMAKE_TEST_NAME}
PROPERTIES
# set target compile options
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
CXX_SCAN_FOR_MODULES OFF
)

target_include_directories(${CMAKE_TEST_NAME}
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/examples/routing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cmake-format: off
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on

Expand All @@ -17,7 +17,7 @@ set_target_properties(
pdptw_mixed_fleet
cvrp_daily_deliveries
PROPERTIES
CUDA_STANDARD 17
CUDA_STANDARD 20
CUDA_STANDARD_REQUIRED ON
)

Expand Down
Loading