Make "make test" at the top of the source tree run the tests.
[grantlee:grantlee.git] / CMakeLists.txt
1 project(Grantlee)
2
3 cmake_minimum_required(VERSION 2.6)
4
5 find_package(Qt4 4.5.0 REQUIRED)
6
7 option( BUILD_CORE "Build the Grantlee core library" TRUE )
8 option( BUILD_GUI "Build the Grantlee gui library" TRUE )
9 option( BUILD_MAIN_PLUGINS "Build the Grantlee plugins" TRUE )
10 option( BUILD_SCRIPT_PLUGIN "Build the Grantlee scriptable tags plugin" TRUE )
11 option( BUILD_TESTS "Build the Grantlee tests" TRUE )
12
13 if (BUILD_TESTS)
14   enable_testing()
15 endif()
16
17 set(CMAKE_MODULE_PATH ${Grantlee_SOURCE_DIR}/cmake/modules)
18
19 if (CMAKE_COMPILER_IS_GNUCXX)
20   set (CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
21   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-check-new -fno-common -pedantic-errors")
22   if (NOT MINGW)
23     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
24   else ()
25     # http://mail.kde.org/pipermail/kde-windows/2007-December/001692.html
26     # http://lists.trolltech.com/pipermail/qt-interest/2009-July/009829.html
27     # qt is always compiled with QT_NO_DEBUG under mingw,
28     # so we need to compile stuff linked against it
29     # the same or otherwise QPluginLoader rejects plugins
30     add_definitions(-DQT_NO_DEBUG)
31   endif ()
32 endif()
33
34 set(Grantlee_VERSION_MAJOR 0)
35 set(Grantlee_VERSION_MINOR 1)
36 set(Grantlee_VERSION_PATCH 0)
37 set(Grantlee_MIN_PLUGIN_VERSION 1)
38
39 set(Grantlee_MAJOR_MINOR_VERSION_STRING "${Grantlee_VERSION_MAJOR}.${Grantlee_VERSION_MINOR}" )
40 set(Grantlee_VERSION_STRING "${Grantlee_VERSION_MAJOR}.${Grantlee_VERSION_MINOR}.${Grantlee_VERSION_PATCH}" )
41
42 set (LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name (eg. '64')")
43
44 set( LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} )
45 set( PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/grantlee/${Grantlee_MAJOR_MINOR_VERSION_STRING} )
46 set( BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin )
47 set( INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include )
48 set( DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps )
49 set( CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
50
51 set(Grantlee_USE_FILE "${Grantlee_SOURCE_DIR}/cmake/modules/GrantleeUse.cmake")
52
53 if (BUILD_CORE)
54   set(Grantlee_CORE_LIBRARY "grantlee_core")
55   set(Grantlee_CORE_LIBRARIES ${Grantlee_CORE_LIBRARY} ${QT_QTCORE_LIBRARIES} )
56   add_subdirectory(corelib)
57 endif()
58
59 if (BUILD_GUI)
60   set(Grantlee_GUI_LIBRARY "grantlee_gui")
61   set(Grantlee_GUI_LIBRARIES ${Grantlee_GUI_LIBRARY} ${QT_QTGUI_LIBRARIES} )
62   add_subdirectory(gui)
63 endif()
64
65 if (BUILD_MAIN_PLUGINS)
66   add_subdirectory(loadertags)
67   add_subdirectory(defaulttags)
68
69   add_subdirectory(defaultfilters)
70 endif()
71
72 if (BUILD_SCRIPT_PLUGIN)
73   add_subdirectory(scriptabletags)
74 endif()
75
76 if (BUILD_TESTS)
77   add_subdirectory(tests)
78 endif()
79
80 configure_file(
81   "${CMAKE_MODULE_PATH}/GrantleeConfig.cmake.in"
82   "${Grantlee_BINARY_DIR}/GrantleeConfig.cmake"
83   IMMEDIATE @ONLY
84 )
85
86 configure_file(
87   "${CMAKE_MODULE_PATH}/GrantleeConfigVersion.cmake.in"
88   "${Grantlee_BINARY_DIR}/GrantleeConfigVersion.cmake"
89   IMMEDIATE @ONLY
90 )
91
92 install(FILES
93   "${Grantlee_BINARY_DIR}/GrantleeConfig.cmake"
94   "${Grantlee_BINARY_DIR}/GrantleeConfigVersion.cmake"
95   DESTINATION "${LIB_INSTALL_DIR}/grantlee")
96
97 install(FILES
98   "${CMAKE_MODULE_PATH}/GrantleeUse.cmake"
99   DESTINATION "${PLUGIN_INSTALL_DIR}"
100 )
101
102 # Add support for an uninstall target
103 configure_file(
104   "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
105   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
106   IMMEDIATE @ONLY)
107
108 add_custom_target(uninstall
109   "${CMAKE_COMMAND}" -P
110   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
111
112 find_package(Doxygen)
113 if (DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
114   message (STATUS "Doxygen and dot found. make docs target is available")
115   # Add support for a docs target
116
117   set(TAGFILES "${CMAKE_SOURCE_DIR}/scripts/qttags.tag=http://qt.nokia.com/doc/${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}")
118   set(DOCS_OUTPUT_DIRECTORY "@CMAKE_BINARY_DIR@/apidocs")
119   configure_file(
120     "${CMAKE_MODULE_PATH}/Doxyfile.in"
121     "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
122     IMMEDIATE @ONLY)
123
124   # Add support for a Qt assistant docs target
125   # qttags.tag is too big to distribute with Grantlee. Get it
126   # from http://api.kde.org/kdereview-api/kdereview.tar.gz for example.
127   if(EXISTS ${CMAKE_SOURCE_DIR}/scripts/qttags.tag)
128     set(DOCS_OUTPUT_DIRECTORY "@CMAKE_BINARY_DIR@/qtdocs")
129     set(TAGFILES "${CMAKE_SOURCE_DIR}/scripts/qttags.tag=qthelp://com.trolltech.qt/qdoc/")
130     set(GENERATE_QHP "yes")
131
132     configure_file(
133       "${CMAKE_MODULE_PATH}/Doxyfile.in"
134       "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt"
135       IMMEDIATE @ONLY)
136   endif()
137
138   set( DOCS_ARGS ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" )
139   if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt")
140     set(DOCS_ARGS ${DOCS_ARGS} COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt" )
141   endif()
142
143   add_custom_target(docs
144     ${DOCS_ARGS}
145   )
146 endif()
147