summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-03 02:20:09 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-03 02:20:09 +0100
commite7893cc54fb0eaba0cfe88ff44cf52a3f7ff2200 (patch)
treee8036848eae496deea839ec35389d710b54cd18c /cmake
parentd04123c9ed17d7a590702cd574e651aa78021a5c (diff)
downloadfastd-e7893cc54fb0eaba0cfe88ff44cf52a3f7ff2200.tar
fastd-e7893cc54fb0eaba0cfe88ff44cf52a3f7ff2200.zip
Even nicer method specification
Diffstat (limited to 'cmake')
-rw-r--r--cmake/fastd_module.cmake41
1 files changed, 41 insertions, 0 deletions
diff --git a/cmake/fastd_module.cmake b/cmake/fastd_module.cmake
new file mode 100644
index 0000000..1c2da9d
--- /dev/null
+++ b/cmake/fastd_module.cmake
@@ -0,0 +1,41 @@
+function(fastd_module type name)
+ string(TOUPPER "${type}" TYPE)
+
+ string(REPLACE - _ name_ "${name}")
+ string(TOUPPER "${name_}" NAME)
+
+ set(WITH_${TYPE}_${NAME} TRUE CACHE BOOL "Include the ${name} ${type}")
+
+ if(WITH_${TYPE}_${NAME})
+ add_library(${type}_${name_} STATIC ${ARGN})
+ set_property(TARGET ${type}_${name_} PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
+
+ set_property(TARGET ${type}s APPEND PROPERTY LINK_LIBRARIES ${type}_${name_})
+
+ list(APPEND ${TYPE}S ${name_})
+
+ set_property(GLOBAL APPEND PROPERTY FASTD_${TYPE}S ${name_})
+ endif(WITH_${TYPE}_${NAME})
+endfunction(fastd_module)
+
+function(fastd_module_include_directories type name)
+ string(TOUPPER "${type}" TYPE)
+
+ string(REPLACE - _ name_ "${name}")
+ string(TOUPPER "${name_}" NAME)
+
+ if(WITH_${TYPE}_${NAME})
+ target_include_directories(${type}_${name_} PRIVATE ${ARGN})
+ endif(WITH_${TYPE}_${NAME})
+endfunction(fastd_module_include_directories)
+
+function(fastd_module_link_libraries type name)
+ string(TOUPPER "${type}" TYPE)
+
+ string(REPLACE - _ name_ "${name}")
+ string(TOUPPER "${name_}" NAME)
+
+ if(WITH_${TYPE}_${NAME})
+ target_link_libraries(${type}_${name_} ${ARGN})
+ endif(WITH_${TYPE}_${NAME})
+endfunction(fastd_module_link_libraries)