MapWizard: move most recently used URL on top of static server history (and make...
[marble:marble.git] / MarbleMacros.cmake
1 # the place to put in common cmake macros
2 # this is needed to minimize the amount of errors to do
3 macro( marble_add_plugin _target_name )
4 set( _src ${ARGN} )
5 if( QTONLY )
6     qt4_automoc( ${_src} )
7     add_library( ${_target_name} MODULE ${_src} )
8     target_link_libraries( ${_target_name} ${QT_QTCORE_LIBRARY}
9                                            ${QT_QTDBUS_LIBRARY}
10                                            ${QT_QTGUI_LIBRARY}
11                                            ${QT_QTXML_LIBRARY}
12                                            ${QT_QTSVG_LIBRARY}
13                                            ${QT_QTNETWORK_LIBRARY}
14                                            ${QT_QTMAIN_LIBRARY}
15                                            ${${_target_name}_LIBS}
16                                            marblewidget )
17     install( TARGETS ${_target_name} DESTINATION ${MARBLE_PLUGIN_INSTALL_PATH} )
18 else( QTONLY )
19     kde4_add_plugin( ${_target_name} ${_src} )
20     target_link_libraries( ${_target_name} ${QT_QTCORE_LIBRARY}
21                                            ${QT_QTDBUS_LIBRARY}
22                                            ${QT_QTGUI_LIBRARY}
23                                            ${QT_QTXML_LIBRARY}
24                                            ${QT_QTSVG_LIBRARY}
25                                            ${QT_QTNETWORK_LIBRARY}
26                                            ${KDE4_KDECORE_LIBRARY}
27                                            ${KDE4_KDEUI_LIBRARY}
28                                            ${KDE4_KIO_LIBRARY}
29                                            ${QT_QTMAIN_LIBRARY}
30                                            ${${_target_name}_LIBS}
31                                            marblewidget )
32     install( TARGETS ${_target_name} DESTINATION ${MARBLE_PLUGIN_INSTALL_PATH} )
33 endif( QTONLY )
34
35 set_target_properties( ${_target_name} PROPERTIES 
36                        INSTALL_RPATH_USE_LINK_PATH TRUE  
37                        SKIP_BUILD_RPATH TRUE 
38                        BUILD_WITH_INSTALL_RPATH TRUE 
39                      )
40
41 endmacro( marble_add_plugin _target_name )
42
43 # these plugins are slightly different
44
45 macro( marble_add_designer_plugin _target_name )
46 set( _src ${ARGN} )
47
48 qt4_add_resources( _src ../../../marble.qrc )
49
50 if( QTONLY )
51     qt4_automoc( ${_src} )
52     add_library( ${_target_name} MODULE ${_src} )
53     target_link_libraries( ${_target_name} ${QT_QTCORE_LIBRARY}
54                                            ${QT_QTDBUS_LIBRARY}
55                                            ${QT_QTGUI_LIBRARY}
56                                            ${QT_QTXML_LIBRARY}
57                                            ${QT_QTSVG_LIBRARY}
58                                            ${QT_QTNETWORK_LIBRARY}
59                                            ${QT_QTMAIN_LIBRARY}
60                                            ${${_target_name}_LIBS}
61                                            marblewidget )
62     install( TARGETS ${_target_name} DESTINATION ${QT_PLUGINS_DIR}/designer )
63 else( QTONLY )
64     kde4_add_plugin( ${_target_name} ${_src} )
65     target_link_libraries( ${_target_name} ${QT_QTCORE_LIBRARY}
66                                            ${QT_QTDBUS_LIBRARY}
67                                            ${QT_QTGUI_LIBRARY}
68                                            ${QT_QTXML_LIBRARY}
69                                            ${QT_QTSVG_LIBRARY}
70                                            ${QT_QTNETWORK_LIBRARY}
71                                            ${KDE4_KDECORE_LIBRARY}
72                                            ${KDE4_KDEUI_LIBRARY}
73                                            ${KDE4_KIO_LIBRARY}
74                                            ${QT_QTMAIN_LIBRARY}
75                                            ${${_target_name}_LIBS}
76                                            marblewidget )
77     install( TARGETS ${_target_name} DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/designer )
78 endif( QTONLY )
79
80 set_target_properties( ${_target_name} PROPERTIES 
81                        INSTALL_RPATH_USE_LINK_PATH TRUE  
82                        SKIP_BUILD_RPATH TRUE 
83                        BUILD_WITH_INSTALL_RPATH TRUE 
84                      )
85
86 endmacro( marble_add_designer_plugin _target_name )
87
88 macro( marble_add_declarative_plugin _target_name )
89 set( _src ${ARGN} )
90 qt4_automoc( ${_src} )
91 add_library( ${_target_name} MODULE ${_src} )
92 target_link_libraries( ${_target_name} ${QT_QTCORE_LIBRARY}
93                                            ${QT_QTDBUS_LIBRARY}
94                                            ${QT_QTGUI_LIBRARY}
95                                            ${QT_QTXML_LIBRARY}
96                                            ${QT_QTSVG_LIBRARY}
97                                            ${QT_QTNETWORK_LIBRARY}
98                                            ${QT_QTMAIN_LIBRARY}
99                                            ${${_target_name}_LIBS}
100                                            marblewidget )
101 install( TARGETS ${_target_name} DESTINATION ${MARBLE_PLUGIN_INSTALL_PATH}/org/kde/edu/marble )
102
103 set_target_properties( ${_target_name} PROPERTIES
104                        INSTALL_RPATH_USE_LINK_PATH TRUE
105                        SKIP_BUILD_RPATH TRUE
106                        BUILD_WITH_INSTALL_RPATH TRUE
107                      )
108
109 endmacro( marble_add_declarative_plugin _target_name )
110
111 if( WIN32 )
112     set( DATA_PATH ${CMAKE_INSTALL_PREFIX}/${MARBLE_DATA_PATH} )
113     set( PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${MARBLE_PLUGIN_PATH} )
114 else( WIN32 )
115     set( DATA_PATH ${MARBLE_DATA_PATH} )
116     set( PLUGIN_PATH ${MARBLE_PLUGIN_PATH} )
117 endif( WIN32 )
118
119 macro( marble_add_test TEST_NAME )
120     if( BUILD_MARBLE_TESTS )
121         set( ${TEST_NAME}_SRCS ${TEST_NAME}.cpp ${ARGN} )
122         if( QTONLY )
123             qt4_generate_moc( ${TEST_NAME}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.moc )
124             include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
125             set( ${TEST_NAME}_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.moc ${${TEST_NAME}_SRCS} )
126           
127             add_executable( ${TEST_NAME} ${${TEST_NAME}_SRCS} )
128         else( QTONLY )
129             kde4_add_executable( ${TEST_NAME} ${${TEST_NAME}_SRCS} )
130         endif( QTONLY )
131         target_link_libraries( ${TEST_NAME} ${QT_QTMAIN_LIBRARY}
132                                             ${QT_QTCORE_LIBRARY} 
133                                             ${QT_QTGUI_LIBRARY} 
134                                             ${QT_QTTEST_LIBRARY} 
135                                             marblewidget )
136         set_target_properties( ${TEST_NAME} PROPERTIES 
137                                COMPILE_FLAGS "-DDATA_PATH=\"\\\"${DATA_PATH}\\\"\" -DPLUGIN_PATH=\"\\\"${PLUGIN_PATH}\\\"\"" )
138         add_test( ${TEST_NAME} ${TEST_NAME} )
139     endif( BUILD_MARBLE_TESTS )
140 endmacro( marble_add_test TEST_NAME )