]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Ensure radiant is able to run q3map2 and other tools
authorMattia Basaglia <mattia.basaglia@gmail.com>
Thu, 30 Jul 2015 08:13:59 +0000 (10:13 +0200)
committerMattia Basaglia <mattia.basaglia@gmail.com>
Thu, 30 Jul 2015 08:13:59 +0000 (10:13 +0200)
CMakeLists.txt
libs/stream/stringstream.h
tools/CMakeLists.txt
tools/quake2/CMakeLists.txt
tools/quake3/CMakeLists.txt

index aed33ce6a5efb92aa6a515ef033cc80b61be35a2..aa31feb8b14514e8ac6f3410f85024f65ea48e5f 100644 (file)
@@ -23,14 +23,14 @@ if(GIT_VERSION)
     )
 endif()
 
-if(WIN32)
-    set(RADIANT_EXECUTABLE "exe")
+if(CMAKE_EXECUTABLE_SUFFIX)
+    set(RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
 else()
     execute_process(COMMAND uname -m
         OUTPUT_VARIABLE RADIANT_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
 endif()
-set(RADIANT_ABOUTMSG "Custom build" CACHE STRING "About message")
 
+set(RADIANT_ABOUTMSG "Custom build" CACHE STRING "About message")
 message(STATUS "Building ${PROJECT_NAME} ${RADIANT_VERSION_STRING} ${RADIANT_ABOUTMSG}")
 
 
index 386093fe4a149b040adeca6de904978c84fcd233..63823b4c55e229580775a40fd29f54d02cb7dfa3 100644 (file)
@@ -30,6 +30,7 @@
 /// \brief A wrapper around a STL vector of char.
 /// Maintains a null-terminated array of char.
 /// Provides a limited STL-style interface to push and pop characters at the end of the string.
+/// \todo That vector<char> must become a std::string, and not NUL terminated. Maybe the whole class can be replaced by std::string
 class StringBuffer
 {
 std::vector<char> m_string;
index 22033f1257952535cb1859b9965ee1e6df9ffbb9..e16c7ac6e7e86a68104867785c3302be00301285 100644 (file)
@@ -2,6 +2,16 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_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 -T "$<TARGET_FILE_NAME:${name}>" "${CMAKE_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}"
+            VERBATIM
+        )
+    endif()
+endmacro()
+
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.c.in" "${CMAKE_BINARY_DIR}/version.c")
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
 add_subdirectory(quake3)
index 8dc03830f5459c11f82052289ea1b98771f1778a..82867102cc838741e024ae1e6c3a8f7c885ea3fb 100644 (file)
@@ -6,7 +6,7 @@ include_directories("${CMAKE_SOURCE_DIR}/include")
 find_package(LibXml2 REQUIRED)
 include_directories(${LIBXML2_INCLUDE_DIR})
 
-add_executable(q2map EXCLUDE_FROM_ALL
+radiant_tool(q2map EXCLUDE_FROM_ALL
    common/bspfile.c
    common/bspfile.h
    common/cmdlib.c
@@ -61,7 +61,7 @@ target_link_libraries(q2map
     l_net
 )
 
-add_executable(qdata3 EXCLUDE_FROM_ALL
+radiant_tool(qdata3 EXCLUDE_FROM_ALL
    common/bspfile.c
    common/bspfile.h
    common/cmdlib.c
@@ -101,7 +101,7 @@ target_link_libraries(qdata3
 )
 
 # Why is the /common stuff duplicated for qdata_heretic2?
-add_executable(h2data EXCLUDE_FROM_ALL
+radiant_tool(h2data EXCLUDE_FROM_ALL
    qdata_heretic2/common/bspfile.c
    qdata_heretic2/common/bspfile.h
    qdata_heretic2/common/cmdlib.c
index 29e119adc0bd851c4b1d53f6193eea5ebb678353..dfd11469f1a83ee2c0e80fd16d88fac455ad6123 100644 (file)
@@ -16,7 +16,7 @@ include_directories(${LIBXML2_INCLUDE_DIR})
 find_package(ZLIB REQUIRED)
 include_directories(${ZLIB_INCLUDE_DIRS})
 
-add_executable(q3map2
+radiant_tool(q3map2
     common/cmdlib.c
     common/cmdlib.h
     common/imagelib.c
@@ -119,7 +119,7 @@ target_link_libraries(q3map2
     picomodel
 )
 
-add_executable(q3data
+radiant_tool(q3data
     common/aselib.c
     common/aselib.h
     common/bspfile.c