use or build

Hi

I have lib installed in /usr/local/lib. I try to use it as package in other project. I create .cmake file and i put it in appropriate directory. Package was found by cmake but linker error occurred. Is a way in cmake to set up LD_LIBRARY_PATH? Maybe is in cmake better way to solve this problem?

Without knowing the specifics of your project, I’d suggest taking a look at the packages documentation. Also, CMake prefers to use absolute paths to libraries, rather than -l and -L flags. Is the link error happening at compile/link time or run time?

Thanks for response. Error occurred in linking process. When I copy libXCLZ4.so to /usr/lib problem disappeared.

critical part in first CMakeLists.txt

#instalation
if(UNIX)
set_target_properties ( XCLZ4 PROPERTIES PUBLIC_HEADER “include/CLZ4.h” )
install( TARGETS XCLZ4 DESTINATION lib/X PUBLIC_HEADER DESTINATION include/X )
message ( ${PRFIX}/X )
install( FILES XCLZ4Config.cmake DESTINATION /usr/local/lib/cmake )
elseif ( WIN32 )
endif()

whole XCLZ4Config.cmake

set( XCLZ4_INCLUDE_DIRS ${PREFIX}/include/X )
set( XCLZ4_LIBRARIES ${PREFIX}/lib/X/libXCLZ4.so)

Library and XCLZ4Config.cmake after installation process was copied in to appropriate localization.

critical part of second CMakeLists.txt ( in which i try to use libXCLZ4.so )

find_package (XCLZ4)
if( XCLZ4_FOUND )
target_link_libraries( XLogger PRIVATE XCLZ4 )
else()
add_subdirectory( ${CMAKE_SOURCE_DIR}/XLZ4 build/XLZ4 )
endif()