Fix GeographicLib linking: use TARGET_LINK_LIBRARIES directly and add LINK_DIRECTORIES
- Changed from NGL_TARGET_LINK_LIBRARIES to TARGET_LINK_LIBRARIES for GeographicLib - Added TARGET_LINK_DIRECTORIES to ensure linker finds the library - Applied to LtsCoordTrans library, tools, and test executable Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 file changed
+7
-2
@@ -23,10 +23,11 @@ NGL_TARGET_LINK_LIBRARIES(LtsCoordTrans
|
||||
Qt6::Core
|
||||
)
|
||||
if (GeographicLib_FOUND)
|
||||
NGL_TARGET_LINK_LIBRARIES(LtsCoordTrans
|
||||
TARGET_LINK_LIBRARIES(LtsCoordTrans
|
||||
PRIVATE ${GeographicLib_LIBRARIES}
|
||||
)
|
||||
TARGET_INCLUDE_DIRECTORIES(LtsCoordTrans PRIVATE ${GeographicLib_INCLUDE_DIRS})
|
||||
TARGET_LINK_DIRECTORIES(LtsCoordTrans PRIVATE ${GeographicLib_LIBRARY_DIRS})
|
||||
else()
|
||||
message(STATUS "GeographicLib not found; building LtsCoordTrans without it")
|
||||
endif()
|
||||
@@ -67,11 +68,12 @@ IF(TARGET LtsCoordTrans)
|
||||
SET(_tools lonlat2mgrs mgrs2lonlat)
|
||||
FOREACH(_tool ${_tools})
|
||||
NGL_ADD_EXECUTABLE(ALL ${_tool} ${_tool}.cpp)
|
||||
NGL_TARGET_LINK_LIBRARIES(${_tool}
|
||||
TARGET_LINK_LIBRARIES(${_tool}
|
||||
Qt6::Core
|
||||
${GeographicLib_LIBRARIES}
|
||||
)
|
||||
TARGET_INCLUDE_DIRECTORIES(${_tool} PRIVATE ${GeographicLib_INCLUDE_DIRS})
|
||||
TARGET_LINK_DIRECTORIES(${_tool} PRIVATE ${GeographicLib_LIBRARY_DIRS})
|
||||
NGL_INSTALL_TARGET(${_tool})
|
||||
ENDFOREACH()
|
||||
ENDIF()
|
||||
@@ -95,5 +97,8 @@ IF(BUILD_TESTING AND TARGET LtsCoordTrans)
|
||||
${GeographicLib_LIBRARIES}
|
||||
)
|
||||
TARGET_INCLUDE_DIRECTORIES(lts_coord_trans_unit_test PRIVATE ${GeographicLib_INCLUDE_DIRS})
|
||||
if (GeographicLib_FOUND)
|
||||
TARGET_LINK_DIRECTORIES(lts_coord_trans_unit_test PRIVATE ${GeographicLib_LIBRARY_DIRS})
|
||||
endif()
|
||||
ADD_TEST(NAME lts_coord_trans_unit_test COMMAND $<TARGET_FILE:lts_coord_trans_unit_test>)
|
||||
ENDIF()
|
||||
Reference in new issue
Block a user