Using CMAKE_CURRENT_[SOURCE|BINARY]_DIR 17/214817/7
authoradam.b <adam.b@samsung.com>
Thu, 26 Sep 2019 14:42:05 +0000 (15:42 +0100)
committeradam.b <adam.b@samsung.com>
Mon, 30 Sep 2019 15:28:06 +0000 (16:28 +0100)
Using CMAKE_CURRENT_[SOURCE|BINARY]_DIR to keep all paths relative.

Change-Id: I5b4f380fcc6d3cd7579530afe2660ce450e2e9ea

build/tizen/CMakeLists.txt

index 02808bc..f25af3a 100644 (file)
@@ -30,6 +30,12 @@ OPTION(ENABLE_COVERAGE       "Coverage" OFF)
 # Define non-boolean options to CMake
 SET(WITH_STYLE               "480x800" CACHE STRING "Select the style folder to use")
 
+# from root/build/tizen, get back to root
+SET(ROOT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../)
+
+# Make sure the path is absolute
+GET_FILENAME_COMPONENT(ROOT_SRC_DIR ${ROOT_SRC_DIR} ABSOLUTE)
+
 # Style folder
 SET( STYLE_BASE_DIR ${ROOT_SRC_DIR}/dali-toolkit/styles )
 SET( STYLE_DIR ${STYLE_BASE_DIR}/${dali_style} )
@@ -39,13 +45,13 @@ SET( toolkit_styles_dir ${STYLE_DIR} )
 SET( toolkit_style_images_dir ${STYLE_DIR}/images )
 
 IF( $ENV{DALI_DATA_RW_DIR} )
-  SET( dataReadWriteDir ${DALI_DATA_RW_DIR}/ )
+  SET( dataReadWriteDir $ENV{DALI_DATA_RW_DIR}/ )
 ELSE()
   SET( dataReadWriteDir ${CMAKE_INSTALL_PREFIX}/share/dali/ )
 ENDIF()
 
 IF( $ENV{DALI_DATA_RO_DIR} )
-  SET( dataReadOnlyDir ${DALI_DATA_RO_DIR}/ )
+  SET( dataReadOnlyDir $ENV{DALI_DATA_RO_DIR}/ )
 ELSE()
   SET( dataReadOnlyDir ${CMAKE_INSTALL_PREFIX}/share/dali/ )
 ENDIF()
@@ -91,12 +97,6 @@ ENDIF()
 SET( PREFIX ${CMAKE_INSTALL_PREFIX})
 SET( EXEC_PREFIX ${CMAKE_INSTALL_PREFIX})
 
-# from root/build/tizen, get back to root
-SET(ROOT_SRC_DIR ${CMAKE_SOURCE_DIR}/../..)
-
-# Make sure the path is absolute
-GET_FILENAME_COMPONENT(ROOT_SRC_DIR ${ROOT_SRC_DIR} ABSOLUTE)
-
 # Set DALi style
 SET( dali_style ${WITH_STYLE} )
 
@@ -202,7 +202,7 @@ SET_TARGET_PROPERTIES( ${name}
 INSTALL( TARGETS ${name} DESTINATION ${LIB_DIR} )
 
 # Install the pkg-config file
-INSTALL( FILES ${CMAKE_BINARY_DIR}/${CORE_PKG_CFG_FILE} DESTINATION ${LIB_DIR}/pkgconfig )
+INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_PKG_CFG_FILE} DESTINATION ${LIB_DIR}/pkgconfig )
 
 # Glob for resources
 MACRO( COPY_RESOURCES FILE_LIST SRC_RELATIVE_DIRECTORY DESTINATION EXPLICIT_DESTINATION )
@@ -249,6 +249,9 @@ COPY_RESOURCES( "${dali_toolkit_image_files}" "${ROOT_SRC_DIR}" "${dataReadOnlyD
 COPY_RESOURCES( "${dali_toolkit_sound_files}" "${ROOT_SRC_DIR}" "${dataReadOnlyDir}" "./toolkit/sounds" )
 COPY_RESOURCES( "${dali_toolkit_style_images}" "${ROOT_SRC_DIR}" "${dataReadOnlyDir}" "./toolkit/styles/images" )
 
+# The DALI_TOOLKIT_PREFIX must be set if this CMakeLists.txt is executed
+# from the top-level CMake script using ADD_SUBDIRECTORY() to avoid
+# target names duplication with other DALi modules.
 IF( UNIX )
   FIND_PROGRAM( LCOV_BIN "lcov" )
   IF( LCOV_BIN )
@@ -265,20 +268,20 @@ IF( UNIX )
       SET(LCOV_OPTS --rc lcov_branch_coverage=1)
     ENDIF()
 
-    ADD_CUSTOM_TARGET( rename_cov_data ./rename-cov-data )
+    ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}rename_cov_data ./rename-cov-data )
 
-    ADD_CUSTOM_TARGET( cov_data ${LCOV_BIN} ${LCOV_OPTS} --base-directory . --directory . -c -o dali.info
+    ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}cov_data ${LCOV_BIN} ${LCOV_OPTS} --base-directory . --directory . -c -o dali.info
       COMMAND ${LCOV_BIN} ${LCOV_OPTS} --remove dali.info \"*/dali-env/*\" \"/usr/include/*\" "*/dali-env/*" "*solid-color-actor*" "*/dali-toolkit/third-party/*" -o dali.info )
 
-    ADD_CUSTOM_TARGET( coverage genhtml ${LCOV_OPTS} -o ${COVERAGE_OUTPUT_DIR} dali.info
+    ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}coverage genhtml ${LCOV_OPTS} -o ${COVERAGE_OUTPUT_DIR} dali.info
       DEPENDS cov_data )
 
-    ADD_CUSTOM_TARGET( reset_coverage @${LCOV_BIN} -z --directory `pwd` )
+    ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}reset_coverage @${LCOV_BIN} -z --directory `pwd` )
 
     # Define custom rule for distclean
-    ADD_CUSTOM_TARGET( distclean @echo cleaning for source distribution )
+    ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}distclean @echo cleaning for source distribution )
     ADD_CUSTOM_COMMAND(
-          DEPENDS clean
+          DEPENDS ${DALI_TOOLKIT_PREFIX}clean
           COMMENT "distribution clean"
           COMMAND find
           ARGS    .
@@ -304,7 +307,7 @@ IF( UNIX )
           -name *~ -or
           -name libdali*.so* \)
           | grep -v TC | xargs rm -rf
-          TARGET  distclean
+          TARGET  ${DALI_TOOLKIT_PREFIX}distclean
           VERBATIM
           )