cmake: use relative source and binary directory paths

The config file is not always located in the top level directory of
source tree. So, CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR
are a better alternative than CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR.

Signed-off-by: Vanya A. Sergeev <v@sergeev.io>
This commit is contained in:
oficsu
2020-06-20 03:43:01 +03:00
committed by Vanya A. Sergeev
parent c2aa7d164f
commit 80bc63dd9d

View File

@@ -37,12 +37,12 @@ set_target_properties(periphery PROPERTIES SOVERSION ${VERSION})
include(GNUInstallDirs)
# Generate pkg-config pc file
configure_file(${CMAKE_SOURCE_DIR}/src/libperiphery.pc.in ${CMAKE_BINARY_DIR}/libperiphery.pc @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libperiphery.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libperiphery.pc @ONLY)
# Declare install targets
install(TARGETS periphery DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${periphery_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
install(FILES ${CMAKE_BINARY_DIR}/libperiphery.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libperiphery.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# Declare tests targets
foreach(TEST_SOURCE ${periphery_TESTS})