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})

# 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})
Comment on lines +42 to +72
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

target_link_directories() and target_link_options() are used here, but the project’s top-level cmake_minimum_required(VERSION 3.1) is lower than the CMake versions that provide these commands. As-is, configuring with older CMake will fail. Either bump the minimum required CMake version accordingly, or rewrite this logic using commands/properties available in the current minimum version (while still keeping libraries in target_link_libraries).

Copilot uses AI. Check for mistakes.

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