CMake: install all tools
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 10:48:39 +0000 (20:48 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 10:48:39 +0000 (20:48 +1000)
CMakeLists.txt
radiant/CMakeLists.txt
tools/CMakeLists.txt

index 6876c36..f30b0a2 100644 (file)
@@ -152,10 +152,6 @@ endif ()
 # Radiant
 #-----------------------------------------------------------------------
 
-if (BUILD_RADIANT)
-    add_subdirectory(radiant build)
-endif ()
-
 if (CMAKE_EXECUTABLE_SUFFIX)
     string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
 else ()
@@ -166,7 +162,26 @@ else ()
     )
 endif ()
 
+macro(radiant_tool name)
+    add_executable(${name} ${ARGN})
+    install(
+            TARGETS ${name}
+            RUNTIME DESTINATION .
+    )
+    if (NOT (CMAKE_EXECUTABLE_SUFFIX STREQUAL ".${RADIANT_EXECUTABLE}"))
+        add_custom_command(TARGET ${name} POST_BUILD
+                COMMAND ln -f -s "$<TARGET_FILE_NAME:${name}>" "${PROJECT_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}"
+                VERBATIM
+                )
+        install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+            ${name}${CMAKE_EXECUTABLE_SUFFIX} \
+            ${CMAKE_INSTALL_PREFIX}/${name}.${RADIANT_EXECUTABLE} \
+        )")
+    endif ()
+endmacro()
+
 if (BUILD_RADIANT)
+    add_subdirectory(radiant build)
     set_target_properties(radiant PROPERTIES
             COMPILE_DEFINITIONS RADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}"
             )
index 8956306..cb38469 100644 (file)
@@ -94,7 +94,7 @@ if (WIN32)
     list(APPEND RADIANTLIST multimon.cpp multimon.h)
 endif()
 
-add_executable(radiant WIN32 radiant.rc ${RADIANTLIST})
+radiant_tool(radiant WIN32 radiant.rc ${RADIANTLIST})
 target_link_libraries(radiant
     ${CMAKE_DL_LIBS}
     ${LIBXML2_LIBRARIES}
@@ -130,8 +130,3 @@ if (X11_LIBRARIES)
 endif ()
 
 copy_dlls(radiant)
-
-install(
-        TARGETS radiant
-        RUNTIME DESTINATION .
-)
index ad32a07..1fcce20 100644 (file)
@@ -1,13 +1,3 @@
 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}>" "${PROJECT_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}"
-                VERBATIM
-                )
-    endif ()
-endmacro()
-
 add_subdirectory(quake3)