Cmake support: fix in tree builds

And add a message that we suggest that out of tree builds are a better
idea.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-20 06:06:32 -07:00
parent 8ab7b5ea7f
commit 0726d4c679

View file

@ -121,6 +121,11 @@ set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${LIBDIVECOMPUTER_LIB
# handle out of tree build correctly
string(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}" "${${PROJECT_NAME}_BINARY_DIR}" insource)
if (insource)
message(STATUS "building in Subsurface source tree - we recommend out of tree builds")
else()
message(STATUE "out of source build from source in ${${PROJECT_NAME}_SOURCE_DIR}")
endif()
get_filename_component(PARENTDIR ${${PROJECT_NAME}_SOURCE_DIR} PATH)
string(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir)
if(NOT (insource OR insourcedir))
@ -467,15 +472,32 @@ endif()
# install a few things so that one can run Subsurface from the build
# directory
add_custom_target(createLinks ALL COMMAND rm -f ${CMAKE_BINARY_DIR}/theme && ln -s ${CMAKE_SOURCE_DIR}/theme ${CMAKE_BINARY_DIR}/theme)
if(NOT insource)
add_custom_target(themeLink ALL
COMMAND
rm -f ${CMAKE_BINARY_DIR}/theme &&
ln -s ${CMAKE_SOURCE_DIR}/theme ${CMAKE_BINARY_DIR}/theme
)
if(NOT NO_PRINTING)
add_custom_target(printing_templates ALL COMMAND rm -f ${CMAKE_BINARY_DIR}/printing_templates && ln -s ${CMAKE_SOURCE_DIR}/printing_templates ${CMAKE_BINARY_DIR}/printing_templates)
add_custom_target(printing_templatesLink ALL
COMMAND
rm -f ${CMAKE_BINARY_DIR}/printing_templates &&
ln -s ${CMAKE_SOURCE_DIR}/printing_templates ${CMAKE_BINARY_DIR}/printing_templates
)
endif()
if(NOT NO_DOCS)
add_custom_target(
documentationLink ALL
COMMAND
mkdir -p ${CMAKE_BINARY_DIR}/Documentation/ &&
rm -f ${CMAKE_BINARY_DIR}/Documentation/images &&
ln -s ${CMAKE_SOURCE_DIR}/Documentation/images ${CMAKE_BINARY_DIR}/Documentation/images
)
endif()
endif()
if(NOT NO_DOCS)
add_custom_target(
documentation ALL
mkdir -p ${CMAKE_BINARY_DIR}/Documentation/ \\;
cp -a ${CMAKE_SOURCE_DIR}/Documentation/images ${CMAKE_BINARY_DIR}/Documentation/ \\;
make -C ${CMAKE_SOURCE_DIR}/Documentation OUT=${CMAKE_BINARY_DIR}/Documentation/ doc
)
endif()