wdmtg/CMakeLists.txt

80 lines
3.0 KiB
CMake

project (wdmtg C)
cmake_minimum_required (VERSION 2.8.12)
# Vala really sucks at producing good C code
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} -Wno-ignored-qualifiers -Wno-incompatible-pointer-types")
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
# Options
option (OPTION_NOINSTALL "Only for developers; work without installing" OFF)
# Version
set (project_VERSION "0.1.0")
# Set some variables
if (OPTION_NOINSTALL)
set (project_SHARE_DIR ${PROJECT_SOURCE_DIR}/share)
elseif (WIN32)
set (project_SHARE_DIR ../share)
set (project_INSTALL_SHARE_DIR share)
else (OPTION_NOINSTALL)
set (project_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME})
set (project_INSTALL_SHARE_DIR share/${PROJECT_NAME})
endif (OPTION_NOINSTALL)
# Gather package information
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package (Vala 0.12 REQUIRED)
find_package (PkgConfig REQUIRED)
pkg_check_modules (dependencies REQUIRED gtk+-3.0 sqlite3 x11 xext xextproto)
# Precompile Vala sources
include (ValaPrecompile)
set (config_path "${PROJECT_BINARY_DIR}/config.vala")
configure_file (${PROJECT_SOURCE_DIR}/config.vala.in "${config_path}")
# I'm not sure what this was about, look at slovnik-gui for more comments;
# seems to be so that symbols are exported for GModule to see
set (symbols_path "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.def")
set (project_VALA_SOURCES ${config_path} ${PROJECT_NAME}.vala xext.vapi)
vala_precompile (${project_VALA_SOURCES}
OUTPUTS project_VALA_C
HEADER ${PROJECT_NAME}.h
SYMBOLS ${symbols_path}
PACKAGES gmodule-2.0 gio-2.0 gtk+-3.0 gee-0.8 sqlite3 x11)
# Include Vala sources as header files, so they appear in the IDE
# but CMake doesn't try to compile them directly
set_source_files_properties (${project_VALA_SOURCES}
PROPERTIES HEADER_FILE_ONLY TRUE)
set (project_SOURCES ${project_VALA_SOURCES} ${project_VALA_C} ${symbols_path})
# Build the executable and install it
include_directories (${dependencies_INCLUDE_DIRS})
link_directories (${dependencies_LIBRARY_DIRS})
add_executable (${PROJECT_NAME} ${project_SOURCES})
target_link_libraries (${PROJECT_NAME} ${dependencies_LIBRARIES})
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
# CPack
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Activity tracker")
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION ${project_VERSION})
set (CPACK_GENERATOR "TGZ;ZIP")
set (CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set (CPACK_SOURCE_IGNORE_FILES "/build;/\\\\.git")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
include (CPack)