Added missing files
authorEnrico Zini <enrico@enricozini.org>
Mon, 14 Dec 2009 11:39:04 +0000 (11:39 +0000)
committerEnrico Zini <enrico@enricozini.org>
Mon, 14 Dec 2009 11:39:04 +0000 (11:39 +0000)
vala.cmake [new file with mode: 0644]
zapolygen/CMakeLists.txt [new file with mode: 0644]

diff --git a/vala.cmake b/vala.cmake
new file mode 100644 (file)
index 0000000..51bfa6c
--- /dev/null
@@ -0,0 +1,81 @@
+include(FindPkgConfig)
+
+find_program(VALAC valac)
+
+function(add_vala_library libname)
+  set(valasources ${ARGN})
+
+  # Get the names of the C sources generated by the vala sources
+  foreach(vs ${valasources})
+    file(RELATIVE_PATH cs ${CMAKE_CURRENT_SOURCE_DIR} ${vs})
+    string(REGEX REPLACE "\\.vala$" ".c" cs ${cs})
+    set(csources ${csources} ${CMAKE_CURRENT_BINARY_DIR}/${cs})
+  endforeach(vs)
+
+  set(header ${CMAKE_CURRENT_BINARY_DIR}/${libname}.h)
+  set(vapi ${CMAKE_CURRENT_BINARY_DIR}/${libname}.vapi)
+
+  set_source_files_properties(${csources} ${header} ${vapi} PROPERTIES GENERATED 1)
+
+  # Export the list of C sources
+  set(${libname}_CSOURCES ${csources} PARENT_SCOPE)
+  
+  # Create --pkg= entries for command line
+  foreach(pkg ${VALA_PACKAGES})
+         set(pkgs ${pkgs} --pkg=${pkg})
+  endforeach(pkg)
+
+  message(DEPENDS ${valasources})
+  message(OUTPUT ${csources} ${CMAKE_CURRENT_BINARY_DIR}/${libname}.h ${CMAKE_CURRENT_BINARY_DIR}/${libname}.vapi)
+  add_custom_command(
+      DEPENDS ${valasources}
+      OUTPUT ${csources} ${header} ${vapi}
+      COMMAND ${VALAC} ${VFLAGS} ${pkgs} -C -H ${header} --library=${libname} ${valasources}
+  )
+endfunction(add_vala_library)
+
+function(add_vala_program progname)
+  set(valasources ${ARGN})
+
+  # Get the names of the C sources generated by the vala sources
+  foreach(vs ${valasources})
+    file(RELATIVE_PATH cs ${CMAKE_CURRENT_SOURCE_DIR} ${vs})
+    string(REGEX REPLACE "\\.vala$" ".c" cs ${cs})
+    set(csources ${csources} ${cs})
+  endforeach(vs)
+
+  set_source_files_properties(${csources} PROPERTIES GENERATED 1)
+
+  # Export the list of C sources
+  set(${progname}_CSOURCES ${csources} PARENT_SCOPE)
+  
+  # Create --pkg= entries for command line
+  foreach(pkg ${VALA_PACKAGES})
+         set(pkgs ${pkgs} --pkg=${pkg})
+  endforeach(pkg)
+
+  add_custom_command(
+      DEPENDS ${valasources}
+      OUTPUT ${csources}
+      COMMAND ${VALAC} ${VFLAGS} ${pkgs} -C ${valasources}
+  )
+endfunction(add_vala_program)
+
+# Requires a prefix: we cannot use TMP as internal prefix because
+# pkg_check_modules will not overwrite variables which already exist, so
+# add_packages would not be able to be called more than once
+function(add_packages prefix)
+  set(packages ${ARGN})
+
+  pkg_check_modules(${prefix} REQUIRED ${packages})
+  add_definitions(${${prefix}_CFLAGS})
+  link_libraries(${${prefix}_LDFLAGS})
+
+  #foreach(pkg ${packages})
+  #  string(REGEX REPLACE "[><=].+" "" modname ${pkg})
+  #  pkg_check_modules(TMP${modname} REQUIRED ${pkg})
+  #  message("FOR ${pkg} CFLAGS ${TMP${modname}_CFLAGS} LIBS ${TMP${modname}_LDFLAGS}")
+  #  add_definitions(${TMP${modname}_CFLAGS})
+  #  link_libraries(${TMP${modname}_LDFLAGS})
+  #endforeach(pkg)
+endfunction(add_packages)
diff --git a/zapolygen/CMakeLists.txt b/zapolygen/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2ba8ae0
--- /dev/null
@@ -0,0 +1,24 @@
+project(zapolygen)
+include(../vala.cmake)
+
+set(zapolygen_version 0.1)
+
+set(packages gtk+-2.0 gee-1.0)
+set(VALA_PACKAGES ${packages} gtkfisheyelist)
+
+add_packages(ZP ${packages})
+
+set(VFLAGS --vapidir=${gtkfisheyelist_BINARY_DIR})
+file(GLOB zpvala *.vala)
+add_vala_program(zapolygen ${zpvala})
+
+include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
+
+# -Werror 
+add_definitions(-Wall -I${gtkfisheyelist_BINARY_DIR})
+link_libraries(gtkfisheyelist-static)
+
+add_executable(zapolygen ${zapolygen_CSOURCES})
+
+install(TARGETS zapolygen RUNTIME DESTINATION bin)
+install(FILES zapolygen-update-info RUNTIME DESTINATION bin)