3 # Library Target: linked against executable and tests.
5 # Generate a config.vala file, which can be used for version
6 # information and feature detection.
8 # "${CMAKE_CURRENT_SOURCE_DIR}/config.vala.in"
9 # "${CMAKE_CURRENT_BINARY_DIR}/config.vala"
12 # You can re-type these if you prefer; putting them in variables makes
13 # it easier to reuse them, and helps explain what each command needs
16 # The name of the C header, without the trailing ".h"
17 set(ROOJSPACKER_HEADER ${PROJECT_NAME})
19 # These are the Vala sources you want to build your library out of.
20 set(ROOJSPACKER_VALA_SOURCES
46 vala_precompile_target(
47 "${ROOJSPACKER_LIBRARY_NAME}-vala"
49 PACKAGES ${ROOJSPACKER_VALA_PACKAGES}
50 VAPI "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_PKG_NAME}.vapi"
51 # GIR "${ROOJSPACKER_GIR_NAME}.gir"
52 HEADER "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_PKG_NAME}.h"
53 ${ROOJSPACKER_VALA_SOURCES})
55 # Compile the library.
57 # By default, we create and install a shared library. If you don't
58 # want to do that, you can change "SHARED" in the below function call
60 add_library(${ROOJSPACKER_LIBRARY_NAME}
62 ${ROOJSPACKER_C_SOURCES})
64 # Make sure the Vala sources are compiled to C before attempting to
66 add_dependencies("${ROOJSPACKER_LIBRARY_NAME}" "${ROOJSPACKER_LIBRARY_NAME}-vala")
68 # Generate a .gitignore
69 file(WRITE ".gitignore" "# Automatically generated by CMake, do not modify.\n")
72 "${CMAKE_SHARED_LIBRARY_PREFIX}${ROOJSPACKER_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}*"
73 "${CMAKE_STATIC_LIBRARY_PREFIX}${ROOJSPACKER_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}"
74 "${CMAKE_SHARED_LIBRARY_PREFIX}${ROOJSPACKER_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${ROOJSPACKER_VERSION_API}"
75 "${CMAKE_SHARED_LIBRARY_PREFIX}${ROOJSPACKER_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${ROOJSPACKER_VERSION_API}.${ROOJSPACKER_VERSION_REVISION}"
76 "${ROOJSPACKER_PKG_NAME}.pc"
78 file(APPEND ".gitignore" "/${file}\n")
80 foreach(file ${ROOJSPACKER_C_SOURCES})
81 string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" file ${file})
82 file(APPEND ".gitignore" "/${file}\n")
85 # Define the gettext domain
86 #set_property (TARGET ${ROOJSPACKER_LIBRARY_NAME}
87 # APPEND PROPERTY COMPILE_DEFINITIONS GETTEXT_PACKAGE="${GETTEXT_PACKAGE}")
89 # If you don't want to build and install a shared library, comment out
90 # (or remove) everything below this point.
92 # Set the library's version information
93 set_target_properties (${ROOJSPACKER_LIBRARY_NAME} PROPERTIES
94 SOVERSION "${ROOJSPACKER_SOVERSION_CURRENT}.${ROOJSPACKER_SOVERSION_REVISION}.${ROOJSPACKER_SOVERSION_AGE}"
95 VERSION "${ROOJSPACKER_SOVERSION_CURRENT}.${ROOJSPACKER_SOVERSION_REVISION}")
97 # GObject Introspection support
98 #find_package(GObjectIntrospection REQUIRED)
99 # Gir Repositories support
100 #find_file(GIREPOSITORY_FILE GObject-2.0.gir /usr/share/gir-1.0 )
101 #if(GIREPOSITORY_FILE)
103 # message(FATAL_ERROR "Package libgirepository-dev not found.")
106 # We already had valac write a GIR, now we need to compile it to a
108 #gobject_introspection_compile(
109 # "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_GIR_NAME}.typelib"
110 # "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_GIR_NAME}.gir")
112 # Telling CMake you want to install a file doesn't actually get it to
113 # *build* that file. The workaround is to add a custom target which
114 # is always built and depens on the file we want to install.
115 #add_custom_target(typelib ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_GIR_NAME}.typelib")
117 # Install our typelib
118 #install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_GIR_NAME}.typelib"
119 # DESTINATION "${GI_TYPELIB_DIR}")
122 #install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_GIR_NAME}.gir"
123 # DESTINATION "${GI_REPOSITORY_DIR}")
126 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_PKG_NAME}.vapi
127 DESTINATION ${CMAKE_INSTALL_DATADIR}/vala/vapi)
129 # Install the library
131 TARGETS ${ROOJSPACKER_LIBRARY_NAME}
132 RUNTIME DESTINATION bin # On Windows, the DLL goes in the same place as the executables
133 LIBRARY DESTINATION lib # This is where shared libraries (*.so on Linux, *.dynlib on OS X)
134 ARCHIVE DESTINATION lib) # Finally, this is where static libraries (*.a) go
136 # Install the C header
137 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_PKG_NAME}.h
138 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/)
141 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_PKG_NAME}.vapi
142 DESTINATION ${CMAKE_INSTALL_DATADIR}/vala/vapi)
144 # Generate and install a pkg-config file
146 "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in"
147 "${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_PKG_NAME}.pc"
149 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ROOJSPACKER_PKG_NAME}.pc
150 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
152 # Generate documentation
153 #find_package(Valadoc)
154 #if(${VALADOC_FOUND})
155 # valadoc_generate(html
156 # PACKAGE_NAME ${ROOJSPACKER_PKG_NAME}
157 # PACKAGE_VERSION "${ROOJSPACKER_VERSION_MAJOR}.${ROOJSPACKER_VERSION_MINOR}.${ROOJSPACKER_VERSION_REVISION}"
158 # SOURCES ${ROOJSPACKER_VALA_SOURCES}
159 # PACKAGES ${ROOJSPACKER_VALA_PACKAGES})
160 # valadoc_generate(devhelp
162 # PACKAGE_NAME ${ROOJSPACKER_PKG_NAME}
163 # PACKAGE_VERSION "${ROOJSPACKER_VERSION_MAJOR}.${ROOJSPACKER_VERSION_MINOR}.${ROOJSPACKER_VERSION_REVISION}"
164 # SOURCES ${ROOJSPACKER_VALA_SOURCES}
165 # PACKAGES ${ROOJSPACKER_VALA_PACKAGES})
167 # install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/devhelp/${ROOJSPACKER_PKG_NAME}"
168 # DESTINATION "${CMAKE_INSTALL_DATADIR}/devhelp/books")
169 # add_custom_target(doc ALL
170 # DEPENDS html devhelp)