2011-01-22 13:13:05 +01:00
|
|
|
project (logdiag C)
|
2010-09-13 19:24:53 +02:00
|
|
|
cmake_minimum_required (VERSION 2.6.2)
|
|
|
|
|
|
|
|
# Default to 2.6.3 behaviour
|
|
|
|
cmake_policy (VERSION 2.6.3)
|
|
|
|
|
|
|
|
# Options
|
|
|
|
option (OPTION_NOINSTALL "Only for developers; work without installing" OFF)
|
|
|
|
|
|
|
|
if (OPTION_NOINSTALL)
|
|
|
|
set (OPTION_NOINSTALL 1)
|
|
|
|
else (OPTION_NOINSTALL)
|
|
|
|
set (OPTION_NOINSTALL 0)
|
|
|
|
endif (OPTION_NOINSTALL)
|
|
|
|
|
|
|
|
# Version
|
|
|
|
set (project_VERSION_MAJOR "0")
|
|
|
|
set (project_VERSION_MINOR "0")
|
|
|
|
set (project_VERSION_PATCH "1")
|
2010-09-17 19:03:03 +02:00
|
|
|
|
|
|
|
set (project_VERSION "${project_VERSION_MAJOR}")
|
|
|
|
set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}")
|
|
|
|
set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}")
|
2010-09-13 19:24:53 +02:00
|
|
|
|
|
|
|
# For custom modules
|
|
|
|
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
|
|
|
|
# Test this machine
|
|
|
|
include (CheckCSourceCompiles)
|
|
|
|
|
|
|
|
CHECK_C_SOURCE_COMPILES (
|
|
|
|
"typedef struct abc *d;
|
|
|
|
int test (d __restrict x);
|
|
|
|
int main (void) {return 0;}"
|
|
|
|
HAVE_SANE___RESTRICT)
|
|
|
|
|
|
|
|
CHECK_C_SOURCE_COMPILES (
|
|
|
|
"int test (void *restrict x);
|
|
|
|
int main (void) {return 0;}"
|
|
|
|
HAVE_RESTRICT)
|
|
|
|
|
2011-01-22 13:13:05 +01:00
|
|
|
# Automatic retrieval of dependencies
|
2010-09-13 19:24:53 +02:00
|
|
|
if (WIN32)
|
2011-01-22 13:13:05 +01:00
|
|
|
set (WIN32_DEPENDS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/win32-depends)
|
|
|
|
list (APPEND CMAKE_PREFIX_PATH ${WIN32_DEPENDS_PATH})
|
|
|
|
list (APPEND CMAKE_INCLUDE_PATH ${WIN32_DEPENDS_PATH}/lib)
|
|
|
|
list (APPEND CMAKE_C_FLAGS "-mms-bitfields")
|
|
|
|
|
|
|
|
add_custom_target (win32-depends COMMAND ${CMAKE_COMMAND} -P
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Win32Depends.cmake
|
|
|
|
WORKING_DIRECTORY ${WIN32_DEPENDS_PATH})
|
|
|
|
add_custom_target (win32-depends-clean COMMAND ${CMAKE_COMMAND} -E
|
|
|
|
remove_directory ${WIN32_DEPENDS_PATH})
|
2010-09-13 19:24:53 +02:00
|
|
|
endif (WIN32)
|
|
|
|
|
2011-01-22 17:13:56 +01:00
|
|
|
# Generate icons
|
|
|
|
find_program (CONVERT_EXECUTABLE convert)
|
|
|
|
mark_as_advanced (CONVERT_EXECUTABLE)
|
|
|
|
|
|
|
|
if (CONVERT_EXECUTABLE AND NOT WIN32)
|
|
|
|
set (icon_base ${CMAKE_CURRENT_SOURCE_DIR}/share/icons/hicolor)
|
|
|
|
set (icon_svg ${icon_base}/scalable/apps/logdiag.svg)
|
|
|
|
set (icon_size_list 16x16 32x32 48x48)
|
|
|
|
|
|
|
|
set (icon_png_list)
|
2011-01-23 13:26:00 +01:00
|
|
|
set (icon_symbolic_list)
|
2011-01-22 17:13:56 +01:00
|
|
|
foreach (icon_size ${icon_size_list})
|
|
|
|
set (icon_png_path ${icon_base}/${icon_size}/apps)
|
|
|
|
set (icon_png ${icon_png_path}/logdiag.png)
|
|
|
|
list (APPEND icon_png_list ${icon_png})
|
2011-01-23 13:26:00 +01:00
|
|
|
set (icon_symbolic logdiag_icons_${icon_size})
|
|
|
|
list (APPEND icon_symbolic_list ${icon_symbolic})
|
2011-01-22 17:13:56 +01:00
|
|
|
|
2011-01-23 13:26:00 +01:00
|
|
|
add_custom_command (OUTPUT ${icon_symbolic}
|
2011-01-22 17:13:56 +01:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${icon_png_path}
|
|
|
|
COMMAND ${CONVERT_EXECUTABLE} -background none
|
|
|
|
-resize ${icon_size} ${icon_svg} ${icon_png}
|
2011-01-23 13:26:00 +01:00
|
|
|
DEPENDS ${icon_svg} VERBATIM)
|
|
|
|
set_source_files_properties (${icon_symbolic}
|
|
|
|
PROPERTIES SYMBOLIC TRUE)
|
2011-01-22 17:13:56 +01:00
|
|
|
endforeach (icon_size)
|
|
|
|
|
|
|
|
set (icon_ico ${CMAKE_CURRENT_SOURCE_DIR}/share/logdiag.ico)
|
2011-01-23 13:26:00 +01:00
|
|
|
add_custom_target (logdiag_icons DEPENDS ${icon_symbolic_list}
|
2011-01-22 17:13:56 +01:00
|
|
|
COMMAND ${CONVERT_EXECUTABLE} ${icon_png_list} ${icon_ico}
|
2011-01-23 13:26:00 +01:00
|
|
|
COMMENT "Generating logdiag.ico" VERBATIM)
|
2011-01-22 17:13:56 +01:00
|
|
|
endif (CONVERT_EXECUTABLE AND NOT WIN32)
|
|
|
|
|
2010-12-18 15:39:50 +01:00
|
|
|
# Dependencies
|
2011-01-22 13:13:05 +01:00
|
|
|
find_package (GTK2 2.12 REQUIRED gtk)
|
2010-12-18 15:39:50 +01:00
|
|
|
find_package (Lua51 REQUIRED)
|
2010-12-05 15:23:10 +01:00
|
|
|
find_package (JsonGlib REQUIRED)
|
|
|
|
|
2010-09-13 19:24:53 +02:00
|
|
|
# Localization
|
|
|
|
find_package (Gettext)
|
|
|
|
if (GETTEXT_FOUND)
|
|
|
|
set (HAVE_GETTEXT true)
|
|
|
|
file (GLOB project_TRANSLATIONS ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
|
|
|
|
GETTEXT_CREATE_TRANSLATIONS (
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/po/${PROJECT_NAME}.pot
|
|
|
|
ALL ${project_TRANSLATIONS})
|
|
|
|
endif (GETTEXT_FOUND)
|
|
|
|
|
|
|
|
# Documentation
|
2011-01-23 13:49:48 +01:00
|
|
|
# TODO: Add pregenerated docs to the tree
|
2010-12-18 15:39:50 +01:00
|
|
|
find_package (GtkDoc)
|
2010-09-13 19:24:53 +02:00
|
|
|
set (project_DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/reference")
|
|
|
|
|
|
|
|
# Project source files
|
2011-01-10 16:49:13 +01:00
|
|
|
set (liblogdiag_SOURCES
|
|
|
|
liblogdiag/ld-marshal.c
|
|
|
|
liblogdiag/ld-types.c
|
|
|
|
liblogdiag/ld-diagram.c
|
|
|
|
liblogdiag/ld-diagram-object.c
|
|
|
|
liblogdiag/ld-diagram-symbol.c
|
|
|
|
liblogdiag/ld-canvas.c
|
|
|
|
liblogdiag/ld-library.c
|
2011-01-24 06:00:47 +01:00
|
|
|
liblogdiag/ld-library-toolbar.c
|
2011-01-10 16:49:13 +01:00
|
|
|
liblogdiag/ld-symbol-category.c
|
|
|
|
liblogdiag/ld-symbol.c
|
|
|
|
liblogdiag/ld-lua.c
|
|
|
|
liblogdiag/ld-lua-symbol.c)
|
|
|
|
set (liblogdiag_HEADERS
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.h
|
|
|
|
liblogdiag/liblogdiag.h
|
|
|
|
liblogdiag/ld-marshal.h
|
|
|
|
liblogdiag/ld-types.h
|
|
|
|
liblogdiag/ld-diagram.h
|
|
|
|
liblogdiag/ld-diagram-object.h
|
|
|
|
liblogdiag/ld-diagram-symbol.h
|
|
|
|
liblogdiag/ld-canvas.h
|
|
|
|
liblogdiag/ld-library.h
|
2011-01-24 06:00:47 +01:00
|
|
|
liblogdiag/ld-library-toolbar.h
|
2011-01-10 16:49:13 +01:00
|
|
|
liblogdiag/ld-symbol-category.h
|
|
|
|
liblogdiag/ld-symbol.h
|
|
|
|
liblogdiag/ld-lua.h
|
|
|
|
liblogdiag/ld-lua-private.h
|
|
|
|
liblogdiag/ld-lua-symbol.h
|
|
|
|
liblogdiag/ld-lua-symbol-private.h)
|
|
|
|
|
2010-09-13 19:24:53 +02:00
|
|
|
set (logdiag_SOURCES
|
2010-09-17 19:03:03 +02:00
|
|
|
src/ld-window-main.c
|
2011-01-10 16:49:13 +01:00
|
|
|
src/logdiag.c)
|
2010-09-13 19:24:53 +02:00
|
|
|
set (logdiag_HEADERS
|
2011-01-10 16:49:13 +01:00
|
|
|
${liblogdiag_HEADERS}
|
|
|
|
src/ld-window-main.h)
|
2010-09-13 19:24:53 +02:00
|
|
|
|
2011-01-22 17:13:56 +01:00
|
|
|
# Resource compilation for MinGW
|
|
|
|
if (MINGW)
|
|
|
|
set (CMAKE_RC_COMPILER_INIT windres)
|
|
|
|
enable_language (RC)
|
|
|
|
set (CMAKE_RC_FLAGS "-O coff")
|
|
|
|
set (CMAKE_RC_COMPILE_OBJECT
|
|
|
|
"<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>")
|
|
|
|
endif (MINGW)
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set (logdiag_SOURCES
|
|
|
|
${logdiag_SOURCES}
|
|
|
|
share/logdiag.rc)
|
|
|
|
endif (WIN32)
|
|
|
|
|
2010-09-13 19:24:53 +02:00
|
|
|
# Generate a configure file
|
|
|
|
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
|
|
|
include_directories (${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2010-09-18 19:47:33 +02:00
|
|
|
# Generate marshallers
|
2011-01-27 18:56:41 +01:00
|
|
|
find_program (GLIB_GENMARSHAL_EXECUTABLE glib-genmarshal)
|
|
|
|
if (NOT GLIB_GENMARSHAL_EXECUTABLE)
|
|
|
|
message (FATAL_ERROR "glib-genmarshal not found")
|
|
|
|
endif (NOT GLIB_GENMARSHAL_EXECUTABLE)
|
|
|
|
|
2010-09-18 19:47:33 +02:00
|
|
|
function (glib_genmarshal base prefix)
|
2011-01-27 18:56:41 +01:00
|
|
|
get_filename_component (base_path "${base}" PATH)
|
|
|
|
get_filename_component (base_name "${base}" NAME)
|
|
|
|
set (command_base ${GLIB_GENMARSHAL_EXECUTABLE}
|
|
|
|
--prefix ${prefix} "${base_name}.list")
|
|
|
|
|
|
|
|
# On Windows, the final makefile may contain:
|
|
|
|
# cd e:\abc && ...
|
|
|
|
# That won't actually change the directory. We have to do:
|
|
|
|
# cd e:\abc && e: && ...
|
|
|
|
if (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]")
|
|
|
|
string (SUBSTRING "${base_path}" 0 2 base_drive)
|
|
|
|
set (command_base "${base_drive}" && "${command_base}")
|
|
|
|
endif (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]")
|
|
|
|
|
|
|
|
# NOTE: VERBATIM would cause problems, so it is not used here
|
|
|
|
add_custom_command (OUTPUT ${base}.c
|
|
|
|
COMMAND ${command_base} --body > "${base_name}.c"
|
|
|
|
DEPENDS "${base}.list"
|
|
|
|
WORKING_DIRECTORY "${base_path}"
|
|
|
|
COMMENT "Generating marshallers source file")
|
|
|
|
add_custom_command (OUTPUT ${base}.h
|
|
|
|
COMMAND ${command_base} --header > "${base_name}.h"
|
|
|
|
DEPENDS "${base}.list"
|
|
|
|
WORKING_DIRECTORY "${base_path}"
|
|
|
|
COMMENT "Generating marshallers header file")
|
2010-09-18 19:47:33 +02:00
|
|
|
endfunction (glib_genmarshal)
|
|
|
|
|
2011-01-10 16:49:13 +01:00
|
|
|
glib_genmarshal (${CMAKE_CURRENT_SOURCE_DIR}/liblogdiag/ld-marshal
|
2011-01-24 17:18:28 +01:00
|
|
|
ld_marshal)
|
2010-09-18 19:47:33 +02:00
|
|
|
|
2011-01-24 04:42:18 +01:00
|
|
|
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
2011-01-16 18:16:42 +01:00
|
|
|
include_directories (${GTK2_INCLUDE_DIRS}
|
|
|
|
${JSON_GLIB_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
|
2011-01-23 13:49:48 +01:00
|
|
|
set (logdiag_LIBS ${GTK2_LIBRARIES}
|
|
|
|
${JSON_GLIB_LIBRARIES} ${LUA_LIBRARIES})
|
2011-01-10 16:49:13 +01:00
|
|
|
|
|
|
|
# Build the library
|
|
|
|
add_library (liblogdiag STATIC ${liblogdiag_SOURCES} ${liblogdiag_HEADERS})
|
|
|
|
set_target_properties (liblogdiag PROPERTIES OUTPUT_NAME logdiag)
|
|
|
|
|
|
|
|
# Build the executable
|
2011-01-22 13:13:05 +01:00
|
|
|
add_executable (logdiag WIN32 ${logdiag_SOURCES} ${logdiag_HEADERS})
|
2011-01-23 13:49:48 +01:00
|
|
|
target_link_libraries (logdiag liblogdiag ${logdiag_LIBS})
|
2010-09-13 19:24:53 +02:00
|
|
|
|
2010-12-18 15:39:50 +01:00
|
|
|
# Generate documentation
|
|
|
|
if (GTK_DOC_FOUND)
|
|
|
|
GTK_DOC_RUN (WORKING_DIR ${project_DOC_DIR}
|
2011-01-10 16:49:13 +01:00
|
|
|
SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/liblogdiag
|
2011-01-23 13:49:48 +01:00
|
|
|
SCANGOBJ liblogdiag ${logdiag_LIBS}
|
2010-12-18 15:39:50 +01:00
|
|
|
XML ${project_DOC_DIR}/xml --sgml-mode
|
|
|
|
HTML ${project_DOC_DIR}/html)
|
|
|
|
endif (GTK_DOC_FOUND)
|
|
|
|
|
2010-09-13 19:24:53 +02:00
|
|
|
# Installation
|
2011-01-16 18:16:42 +01:00
|
|
|
install (DIRECTORY share/gui share/library
|
|
|
|
DESTINATION share/${CMAKE_PROJECT_NAME})
|
2010-12-18 15:39:50 +01:00
|
|
|
|
2011-01-22 13:13:05 +01:00
|
|
|
if (WIN32)
|
|
|
|
install (TARGETS logdiag DESTINATION .)
|
|
|
|
install (DIRECTORY
|
|
|
|
${WIN32_DEPENDS_PATH}/bin/
|
|
|
|
DESTINATION .
|
|
|
|
FILES_MATCHING PATTERN "*.dll")
|
|
|
|
install (DIRECTORY
|
|
|
|
${WIN32_DEPENDS_PATH}/etc/
|
|
|
|
DESTINATION etc)
|
|
|
|
install (DIRECTORY
|
|
|
|
${WIN32_DEPENDS_PATH}/lib/glib-2.0
|
|
|
|
${WIN32_DEPENDS_PATH}/lib/gtk-2.0
|
|
|
|
${WIN32_DEPENDS_PATH}/lib/gdk-pixbuf-2.0
|
|
|
|
DESTINATION lib)
|
|
|
|
install (DIRECTORY
|
|
|
|
${WIN32_DEPENDS_PATH}/share/locale
|
|
|
|
${WIN32_DEPENDS_PATH}/share/themes
|
|
|
|
DESTINATION share)
|
|
|
|
else (WIN32)
|
|
|
|
install (TARGETS logdiag DESTINATION bin)
|
2010-12-18 15:39:50 +01:00
|
|
|
install (FILES share/logdiag.desktop DESTINATION share/applications)
|
2011-01-16 16:46:48 +01:00
|
|
|
install (DIRECTORY share/icons DESTINATION share)
|
2011-01-16 18:16:42 +01:00
|
|
|
install (DIRECTORY "${project_DOC_DIR}/html/"
|
2011-01-23 15:37:37 +01:00
|
|
|
DESTINATION share/gtk-doc/html/${CMAKE_PROJECT_NAME})
|
2011-01-16 18:16:42 +01:00
|
|
|
install (FILES LICENSE DESTINATION share/doc/${CMAKE_PROJECT_NAME})
|
2011-01-22 13:13:05 +01:00
|
|
|
endif (WIN32)
|
2010-09-13 19:24:53 +02:00
|
|
|
|
|
|
|
# CPack
|
2011-01-16 19:21:39 +01:00
|
|
|
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Schematic editor")
|
2010-09-13 19:24:53 +02:00
|
|
|
set (CPACK_PACKAGE_VENDOR "Přemysl Janouch")
|
|
|
|
set (CPACK_PACKAGE_CONTACT "p.janouch@gmail.com")
|
|
|
|
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
|
|
|
set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
|
|
|
|
set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
|
|
|
|
set (CPACK_PACKAGE_VERSION_PATCH ${project_VERSION_PATCH})
|
2011-01-22 19:48:30 +01:00
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set (CPACK_GENERATOR "NSIS;ZIP")
|
|
|
|
else (WIN32)
|
|
|
|
set (CPACK_GENERATOR "TGZ;ZIP")
|
|
|
|
endif (WIN32)
|
2010-09-13 19:24:53 +02:00
|
|
|
set (CPACK_PACKAGE_FILE_NAME
|
|
|
|
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
|
|
|
set (CPACK_PACKAGE_INSTALL_DIRECTORY
|
2011-01-22 19:48:30 +01:00
|
|
|
"${PROJECT_NAME} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
|
|
|
set (CPACK_NSIS_INSTALLED_ICON_NAME "logdiag.exe")
|
|
|
|
set (CPACK_NSIS_CREATE_ICONS_EXTRA
|
|
|
|
"CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\logdiag.lnk' '\$INSTDIR\\\\logdiag.exe'")
|
|
|
|
set (CPACK_NSIS_DELETE_ICONS_EXTRA
|
|
|
|
"!insertmacro MUI_STARTMENU_GETFOLDER Application $SM_FOLDER
|
|
|
|
Delete '\$SMPROGRAMS\\\\$SM_FOLDER\\\\logdiag.lnk'")
|
|
|
|
|
2010-09-13 19:24:53 +02:00
|
|
|
set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
|
2011-01-27 18:56:41 +01:00
|
|
|
set (CPACK_SOURCE_IGNORE_FILES "/.git;/build;/win32-depends;/liblogdiag/ld-marshal.[ch]")
|
2010-09-13 19:24:53 +02:00
|
|
|
set (CPACK_SOURCE_PACKAGE_FILE_NAME
|
|
|
|
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
|
|
|
|
|
|
|
include (CPack)
|
|
|
|
|