CMake: Use PROJECT_SOURCE_DIR to improve using mosquitto as subdirectory

When mosquitto is included as subdirectory, `CMAKE_SOURCE_DIR` does not refer to the mosquitto top level CMake file, but to the whole project top level CMake.
Use `PROJECT_SOURCE_DIR` instead to refer to the right CMake in both contextes.

Signed-off-by: Pierre Hallot <hallotpierre@gmail.com>
pull/2504/head
Pierre Hallot 4 years ago
parent 74814cc68f
commit 8504f6b70b
No known key found for this signature in database
GPG Key ID: 43BB1CDDD7376D80

@ -10,7 +10,7 @@ cmake_policy(SET CMP0042 NEW)
project(mosquitto) project(mosquitto)
set (VERSION 2.0.14) set (VERSION 2.0.14)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
add_definitions (-DCMAKE -DVERSION=\"${VERSION}\") add_definitions (-DCMAKE -DVERSION=\"${VERSION}\")

@ -8,10 +8,10 @@ if(NOT WIN32)
find_program(XSLTPROC xsltproc OPTIONAL) find_program(XSLTPROC xsltproc OPTIONAL)
if(XSLTPROC) if(XSLTPROC)
function(compile_manpage page) function(compile_manpage page)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/man/${page} add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/man/${page}
COMMAND xsltproc ${CMAKE_SOURCE_DIR}/man/${page}.xml -o ${CMAKE_SOURCE_DIR}/man/ COMMAND xsltproc ${PROJECT_SOURCE_DIR}/man/${page}.xml -o ${PROJECT_SOURCE_DIR}/man/
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/man/${page}.xml) MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/man/${page}.xml)
add_custom_target(${page} ALL DEPENDS ${CMAKE_SOURCE_DIR}/man/${page}) add_custom_target(${page} ALL DEPENDS ${PROJECT_SOURCE_DIR}/man/${page})
endfunction() endfunction()
compile_manpage("mosquitto_ctrl.1") compile_manpage("mosquitto_ctrl.1")

Loading…
Cancel
Save