]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
CMake: behave nicely in multi-project build
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 19 Mar 2016 04:21:09 +0000 (15:21 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 19 Mar 2016 04:21:09 +0000 (15:21 +1100)
CMakeLists.txt
contrib/CMakeLists.txt
include/version.cpp.in
libs/CMakeLists.txt
plugins/CMakeLists.txt
radiant/CMakeLists.txt
tools/CMakeLists.txt
tools/quake2/CMakeLists.txt
tools/quake3/CMakeLists.txt

index bed416a5d4d9db0382b896d22d02b4232637d8fd..d5fb2d61c5907f885284627a0c532dab9274bed8 100644 (file)
@@ -32,9 +32,9 @@ if (GIT_VERSION)
     set(Q3MAP_VERSION "${Q3MAP_VERSION}-git-${GIT_VERSION}")
 endif ()
 
-configure_file("${CMAKE_SOURCE_DIR}/include/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp")
+configure_file("${PROJECT_SOURCE_DIR}/include/version.cpp.in" "${PROJECT_BINARY_DIR}/version.cpp")
 
-add_library(version "${CMAKE_BINARY_DIR}/version.cpp")
+add_library(version "${PROJECT_BINARY_DIR}/version.cpp")
 set_property(TARGET version PROPERTY POSITION_INDEPENDENT_CODE TRUE)
 
 set(RADIANT_ABOUTMSG "Custom build" CACHE STRING "About message")
@@ -183,13 +183,13 @@ set_target_properties(radiant PROPERTIES
 
 add_subdirectory(tools)
 
-if (NOT (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR))
+if (NOT (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR))
     # Copy data files from sources to the build directory
     message(STATUS "Copying data files")
-    file(GLOB DATA_FILES "${CMAKE_SOURCE_DIR}/setup/data/tools/*")
-    file(COPY ${DATA_FILES} DESTINATION "${CMAKE_BINARY_DIR}")
-    file(GLOB DATA_FILES "${CMAKE_SOURCE_DIR}/docs/*")
-    file(COPY ${DATA_FILES} DESTINATION "${CMAKE_BINARY_DIR}/docs")
+    file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/setup/data/tools/*")
+    file(COPY ${DATA_FILES} DESTINATION "${PROJECT_BINARY_DIR}")
+    file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/docs/*")
+    file(COPY ${DATA_FILES} DESTINATION "${PROJECT_BINARY_DIR}/docs")
 endif ()
 
 #-----------------------------------------------------------------------
@@ -199,7 +199,7 @@ endif ()
 option(DOWNLOAD_GAMEPACKS "Download game packs" ON)
 add_custom_target(game_packs
         COMMAND ${CMAKE_COMMAND} -E make_directory games
-        COMMAND DOWNLOAD_GAMEPACKS=yes SOURCE_DIR="${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/install-gamepacks.sh" "${CMAKE_BINARY_DIR}"
+        COMMAND DOWNLOAD_GAMEPACKS=yes SOURCE_DIR="${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/install-gamepacks.sh" "${PROJECT_BINARY_DIR}"
         COMMENT "Downloading game packs"
         )
 add_custom_command(OUTPUT games
index 7ef653372103feffa17f94115e5d54d4f4a62124..e14be811f941b9ef2cfe14036bd995853947300e 100644 (file)
@@ -1,7 +1,7 @@
-include_directories("${CMAKE_SOURCE_DIR}/libs")
-include_directories("${CMAKE_SOURCE_DIR}/include")
+include_directories("${PROJECT_SOURCE_DIR}/libs")
+include_directories("${PROJECT_SOURCE_DIR}/include")
 
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/plugins")
 
 add_custom_target(plugins)
 macro(radiant_plugin name)
index d16aa348d6d82c67e9c296e4c25f4319b60253cb..21283980e7fc9db806637e15a2eca7fb3d0256da 100644 (file)
@@ -1,4 +1,4 @@
-#include "@CMAKE_SOURCE_DIR@/include/version.h"
+#include "@PROJECT_SOURCE_DIR@/include/version.h"
 namespace radiant {
 
 std::string version()
index d46362709caca1a4ecd2d7463f1443d1a8acc001..19ed8fa90a84680262096f70b5e41cd129aaac53 100644 (file)
@@ -1,7 +1,7 @@
 set(CMAKE_POSITION_INDEPENDENT_CODE 1)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories("${CMAKE_SOURCE_DIR}/include")
+include_directories("${PROJECT_SOURCE_DIR}/include")
 
 add_subdirectory(cmdlib)
 add_subdirectory(container)
index b5f2a7af97c22e4d127caeac9de41388713f9e41..3660a68a596dd6428e460bda57736e58b9c0ea9b 100644 (file)
@@ -1,7 +1,7 @@
-include_directories("${CMAKE_SOURCE_DIR}/libs")
-include_directories("${CMAKE_SOURCE_DIR}/include")
+include_directories("${PROJECT_SOURCE_DIR}/libs")
+include_directories("${PROJECT_SOURCE_DIR}/include")
 
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/modules")
 
 add_custom_target(modules)
 macro(radiant_plugin name)
index ab40b2a0038f09cd2e2dcb7fc7f8b7e7494f99d5..aabaef72bb67d2197b35f1ee4f7a5729c8b95396 100644 (file)
@@ -1,9 +1,9 @@
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
 
 find_package(OpenGL REQUIRED)
 
-include_directories("${CMAKE_SOURCE_DIR}/libs")
-include_directories("${CMAKE_SOURCE_DIR}/include")
+include_directories("${PROJECT_SOURCE_DIR}/libs")
+include_directories("${PROJECT_SOURCE_DIR}/include")
 
 string(SUBSTRING ${CMAKE_SHARED_MODULE_SUFFIX} 1 -1 _clibext)
 add_definitions(-DCMAKE_SHARED_MODULE_SUFFIX="${_clibext}")
index a3fee086d6f81ebc8719527103ca7cdfe6b4f6fd..29ce9cdcb08a88a684c9d48957c16d143cf2f628 100644 (file)
@@ -1,18 +1,18 @@
 # Todo split further and actually compile the tools
 
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
 
 macro(radiant_tool name)
     add_executable(${name} ${ARGN})
     if(NOT (CMAKE_EXECUTABLE_SUFFIX STREQUAL RADIANT_EXECUTABLE))
         add_custom_command(TARGET ${name} POST_BUILD
-            COMMAND ln -f -s "$<TARGET_FILE_NAME:${name}>" "${CMAKE_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}"
+            COMMAND ln -f -s "$<TARGET_FILE_NAME:${name}>" "${PROJECT_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}"
             VERBATIM
         )
     endif()
 endmacro()
 
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.c.in" "${CMAKE_BINARY_DIR}/version.c")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.c.in" "${PROJECT_BINARY_DIR}/version.c")
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
 add_subdirectory(quake3)
 add_subdirectory(quake2)
index 82867102cc838741e024ae1e6c3a8f7c885ea3fb..6945ad2708884424591b06242d95b1db3c7d7387 100644 (file)
@@ -1,7 +1,7 @@
 
 include_directories(common)
-include_directories("${CMAKE_SOURCE_DIR}/libs")
-include_directories("${CMAKE_SOURCE_DIR}/include")
+include_directories("${PROJECT_SOURCE_DIR}/libs")
+include_directories("${PROJECT_SOURCE_DIR}/include")
 
 find_package(LibXml2 REQUIRED)
 include_directories(${LIBXML2_INCLUDE_DIR})
@@ -54,7 +54,7 @@ radiant_tool(q2map EXCLUDE_FROM_ALL
    q2map/trace.c
    q2map/tree.c
    q2map/writebsp.c
-       "${CMAKE_BINARY_DIR}/version.c"
+       "${PROJECT_BINARY_DIR}/version.c"
 )
 target_link_libraries(q2map
     ${LIBXML2_LIBRARIES}
@@ -92,7 +92,7 @@ radiant_tool(qdata3 EXCLUDE_FROM_ALL
    qdata/sprites.c
    qdata/tables.c
    qdata/video.c
-       "${CMAKE_BINARY_DIR}/version.c"
+       "${PROJECT_BINARY_DIR}/version.c"
 )
 
 target_link_libraries(qdata3
@@ -166,7 +166,7 @@ radiant_tool(h2data EXCLUDE_FROM_ALL
    qdata_heretic2/tables.c
    qdata_heretic2/tmix.c
    qdata_heretic2/video.c
-       "${CMAKE_BINARY_DIR}/version.c"
+       "${PROJECT_BINARY_DIR}/version.c"
 )
 target_include_directories(h2data BEFORE
     PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/qdata_heretic2/common"
index dfd11469f1a83ee2c0e80fd16d88fac455ad6123..48275e9703629254c696aaf1359414fdca997192 100644 (file)
@@ -1,5 +1,5 @@
 include_directories(common)
-include_directories("${CMAKE_SOURCE_DIR}/libs")
+include_directories("${PROJECT_SOURCE_DIR}/libs")
 
 find_package(GLIB REQUIRED)
 include_directories(${GLIB_INCLUDE_DIRS})
@@ -102,7 +102,7 @@ radiant_tool(q3map2
     q3map2/vis.c
     q3map2/visflow.c
     q3map2/writebsp.c
-    "${CMAKE_BINARY_DIR}/version.c"
+    "${PROJECT_BINARY_DIR}/version.c"
 )
 
 target_link_libraries(q3map2
@@ -155,7 +155,7 @@ radiant_tool(q3data
     q3data/q3data.h
     q3data/stripper.c
     q3data/video.c
-    "${CMAKE_BINARY_DIR}/version.c"
+    "${PROJECT_BINARY_DIR}/version.c"
 )
 
 target_link_libraries(q3data