Skip to content
Open
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
36 changes: 35 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,43 @@ set_target_properties(ncvis
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
LINK_FLAGS "${NCVIS_LINKER_FLAGS}"
BUILD_RPATH "${WXCONFIG_RPATH}/lib"
INSTALL_RPATH "${WXCONFIG_RPATH}/lib"
)

# Link libraries after object files (required for GNU ld)
separate_arguments(WX_LINK_ITEMS NATIVE_COMMAND "${WX_LINK_FLAGS}")
separate_arguments(NC_LINK_ITEMS NATIVE_COMMAND "-lnetcdf ${NC_LINK_FLAGS}")
target_link_directories(ncvis PRIVATE ${NC_LIB_DIR})
Comment on lines +41 to +44

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Build configuration fails on older CMake versions the project still claims to support

The build script now uses two configuration commands (target_link_directories/target_link_options at src/CMakeLists.txt:44 and src/CMakeLists.txt:72) that only exist in newer CMake, while the project still declares support for a much older minimum version, so configuring the build stops with an error for anyone on an older CMake.
Impact: Users with an older but supposedly supported CMake can no longer configure or build the program at all.

Version requirements of the newly introduced CMake commands

The top-level CMakeLists.txt:1 declares cmake_minimum_required(VERSION 3.1). The new code requires:

  • target_link_directories — CMake 3.13+
  • target_link_options — CMake 3.13+
  • separate_arguments(... NATIVE_COMMAND ...) — CMake 3.9+
  • BUILD_RPATH target property — CMake 3.8+

With CMake < 3.13 the configure step aborts with "Unknown CMake command "target_link_directories"". The minimum required version should be bumped to at least 3.13 (and INSTALL.md build instructions updated if it mentions a version).

Prompt for agents
src/CMakeLists.txt now uses target_link_directories and target_link_options (CMake 3.13+), separate_arguments(NATIVE_COMMAND) (3.9+) and the BUILD_RPATH property (3.8+), but the top-level CMakeLists.txt still says cmake_minimum_required(VERSION 3.1). Configuration will fail with 'Unknown CMake command' on older CMake. Raise the declared minimum required version to match what the new commands need, and check whether INSTALL.md documents a CMake version that should be updated too.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


# Split wxWidgets link items into libraries (-l...) and other linker options
set(WX_LIBRARIES "")
set(WX_OPTIONS "")
foreach(item IN LISTS WX_LINK_ITEMS)
if(item MATCHES "^-l.+")
list(APPEND WX_LIBRARIES "${item}")
else()
list(APPEND WX_OPTIONS "${item}")
endif()
endforeach()

# Split NetCDF link items into libraries (-l...) and other linker options
set(NC_LIBRARIES "")
set(NC_OPTIONS "")
foreach(item IN LISTS NC_LINK_ITEMS)
if(item MATCHES "^-l.+")
list(APPEND NC_LIBRARIES "${item}")
else()
list(APPEND NC_OPTIONS "${item}")
endif()
endforeach()

# Link true libraries
target_link_libraries(ncvis PRIVATE ${WX_LIBRARIES} ${NC_LIBRARIES})

# Apply non-library linker options
target_link_options(ncvis PRIVATE ${WX_OPTIONS} ${NC_OPTIONS})

# Install target
INSTALL(TARGETS ncvis
RUNTIME DESTINATION bin
Expand Down