Build system: only build fatelf-utils.c once, add "make install" target.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 01 Oct 2009 01:43:16 -0400
changeset 55 4c824f0ba28c
parent 54 4b17b8e1e454
child 56 911a1a17c95d
Build system: only build fatelf-utils.c once, add "make install" target.
CMakeLists.txt
--- a/CMakeLists.txt	Thu Oct 01 00:52:32 2009 -0400
+++ b/CMakeLists.txt	Thu Oct 01 01:43:16 2009 -0400
@@ -16,14 +16,22 @@
 INCLUDE_DIRECTORIES(include)
 ADD_DEFINITIONS(-Wall -Werror)
 
-ADD_EXECUTABLE(fatelf-glue utils/fatelf-glue.c utils/fatelf-utils.c)
-ADD_EXECUTABLE(fatelf-info utils/fatelf-info.c utils/fatelf-utils.c)
-ADD_EXECUTABLE(fatelf-extract utils/fatelf-extract.c utils/fatelf-utils.c)
-ADD_EXECUTABLE(fatelf-replace utils/fatelf-replace.c utils/fatelf-utils.c)
-ADD_EXECUTABLE(fatelf-remove utils/fatelf-remove.c utils/fatelf-utils.c)
-ADD_EXECUTABLE(fatelf-verify utils/fatelf-verify.c utils/fatelf-utils.c)
-ADD_EXECUTABLE(fatelf-split utils/fatelf-split.c utils/fatelf-utils.c)
-ADD_EXECUTABLE(fatelf-validate utils/fatelf-validate.c utils/fatelf-utils.c)
+ADD_LIBRARY(fatelf-utils STATIC utils/fatelf-utils.c)
+
+MACRO(ADD_FATELF_EXECUTABLE _NAME)
+    ADD_EXECUTABLE(${_NAME} utils/${_NAME}.c)
+    TARGET_LINK_LIBRARIES(${_NAME} fatelf-utils)
+    INSTALL(TARGETS ${_NAME} RUNTIME DESTINATION bin)
+ENDMACRO(ADD_FATELF_EXECUTABLE)
+
+ADD_FATELF_EXECUTABLE(fatelf-glue)
+ADD_FATELF_EXECUTABLE(fatelf-info)
+ADD_FATELF_EXECUTABLE(fatelf-extract)
+ADD_FATELF_EXECUTABLE(fatelf-replace)
+ADD_FATELF_EXECUTABLE(fatelf-remove)
+ADD_FATELF_EXECUTABLE(fatelf-verify)
+ADD_FATELF_EXECUTABLE(fatelf-split)
+ADD_FATELF_EXECUTABLE(fatelf-validate)
 
 # end of CMakeLists.txt ...