Created
January 15, 2018 19:38
-
-
Save danirabbit/ab0c7a1d941ffa03933c84a57d575aed to your computer and use it in GitHub Desktop.
CMake example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# project name | |
project (com.github.yourusername.yourrepositoryname) | |
# where we install data directory (if we have any) | |
set (DATADIR "${CMAKE_INSTALL_PREFIX}/share") | |
# Set our translation domain | |
add_definitions ("-DGETTEXT_PACKAGE=\"${CMAKE_INSTALL_PREFIX}\"") | |
# we're about to use pkgconfig to make sure dependencies are installed so let's find pkgconfig first | |
find_package(PkgConfig) | |
# now let's actually check for the required dependencies | |
pkg_check_modules(DEPS REQUIRED gtk+-3.0) | |
add_definitions(${DEPS_CFLAGS}) | |
link_libraries(${DEPS_LIBRARIES}) | |
link_directories(${DEPS_LIBRARY_DIRS}) | |
# make sure we have vala | |
find_package(Vala REQUIRED) | |
# make sure we use vala | |
include(ValaVersion) | |
# files we want to compile | |
include(ValaPrecompile) | |
vala_precompile(VALA_C ${EXEC_NAME} | |
src/Application.vala | |
# tell what libraries to use when compiling | |
PACKAGES | |
gtk+-3.0 | |
) | |
# tell cmake what to call the executable we just made | |
add_executable(${CMAKE_PROJECT_NAME} ${VALA_C}) | |
# install the binaries we just made | |
install (TARGETS ${CMAKE_PROJECT_NAME} RUNTIME DESTINATION bin) | |
# Include the translations module | |
include (Translations) | |
#Translate our .desktop and .appdata files | |
configure_file_translation(${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.desktop ${CMAKE_SOURCE_DIR}/po/) | |
configure_file_translation(${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.appdata.xml.in ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.appdata.xml ${CMAKE_SOURCE_DIR}/po/) | |
# install our .desktop and .appdata files | |
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${CMAKE_PROJECT_NAME}.desktop DESTINATION ${DATADIR}/applications/) | |
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${CMAKE_PROJECT_NAME}.appdata.xml DESTINATION ${DATADIR}/metainfo/) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment