1 ## -------------------------------------------------------------------------
2 FUNCTION(cpPlugins_GetFiles output)
5 FILE(GLOB_RECURSE _r "${_f}")
8 SET(${output} "${_o}" PARENT_SCOPE)
10 ## -------------------------------------------------------------------------
12 ## -------------------------------------------------------------------------
13 FUNCTION(Wrap_Qt_UI output_files)
14 GET_FILENAME_COMPONENT(_src ${PROJECT_SOURCE_DIR} ABSOLUTE)
15 GET_FILENAME_COMPONENT(_bin ${PROJECT_BINARY_DIR} ABSOLUTE)
19 GET_FILENAME_COMPONENT(_name ${_f} NAME_WE)
20 GET_FILENAME_COMPONENT(_dir ${_f} DIRECTORY)
21 SET(_base_dir ${_src})
22 STRING(FIND "${_dir}" "${_base_dir}" _pos)
24 SET(_base_dir ${_bin})
25 STRING(FIND "${_dir}" "${_base_dir}" _pos)
26 ENDIF(${_pos} EQUAL -1)
27 IF(NOT ${_pos} EQUAL -1)
28 STRING(REPLACE "${_base_dir}/" "" _dir ${_dir})
29 SET(_out_f ${_bin}/${_dir}/ui_${_name}.h)
30 LIST(APPEND _out ${_out_f})
33 COMMAND ${CMAKE_COMMAND} -E make_directory ${_bin}/${_dir}
35 ARGS -o ${_out_f} ${_f}
36 MAIN_DEPENDENCY ${_f} VERBATIM
38 ENDIF(NOT ${_pos} EQUAL -1)
41 SET(${output_files} "${_out}" PARENT_SCOPE)
43 ## -------------------------------------------------------------------------
45 ## -------------------------------------------------------------------------
46 FUNCTION(cpPlugins_PrepareFiles out_src out_hdr out_dirs)
48 ## -- Separe files by extension
54 GET_FILENAME_COMPONENT(_file ${_f} ABSOLUTE)
55 GET_FILENAME_COMPONENT(_e ${_file} EXT)
56 STRING(TOLOWER ${_e} _ext)
57 STRING(COMPARE EQUAL "${_ext}" ".c" _cmp_c)
58 STRING(COMPARE EQUAL "${_ext}" ".cpp" _cmp_cpp)
59 STRING(COMPARE EQUAL "${_ext}" ".cxx" _cmp_cxx)
60 STRING(COMPARE EQUAL "${_ext}" ".h" _cmp_h)
61 STRING(COMPARE EQUAL "${_ext}" ".hpp" _cmp_hpp)
62 STRING(COMPARE EQUAL "${_ext}" ".hxx" _cmp_hxx)
63 STRING(COMPARE EQUAL "${_ext}" ".ui" _cmp_ui)
64 IF(_cmp_c OR _cmp_cpp OR _cmp_cxx)
65 LIST(APPEND _src ${_file})
66 ENDIF(_cmp_c OR _cmp_cpp OR _cmp_cxx)
67 IF(_cmp_h OR _cmp_hpp OR _cmp_hxx)
68 LIST(APPEND _hdr ${_file})
69 GET_FILENAME_COMPONENT(_d ${_file} DIRECTORY)
70 LIST(APPEND _dirs ${_d})
71 ENDIF(_cmp_h OR _cmp_hpp OR _cmp_hxx)
73 LIST(APPEND _ui ${_file})
77 ## -- Wrap possible Qt code
80 ## -- Wrap user interfaces
81 Wrap_Qt_UI(_qt_ui_hdr ${_ui})
82 FOREACH(_h ${_qt_ui_hdr})
83 LIST(APPEND _hdr ${_h})
84 GET_FILENAME_COMPONENT(_d ${_h} DIRECTORY)
85 LIST(APPEND _dirs ${_d})
90 FOREACH(_f ${_hdr} ${_src})
93 STRING(FIND "${_txt}" "Q_OBJECT" _pos)
94 IF(NOT ${_pos} EQUAL -1)
96 QT4_WRAP_CPP(_s ${_f})
97 LIST(APPEND _qt_src ${_s})
98 ENDIF(NOT ${_pos} EQUAL -1)
100 ENDFOREACH(_f ${_hdr} ${_src})
101 LIST(APPEND _src ${_qt_src})
105 SET(${out_src} "${_src}" PARENT_SCOPE)
106 SET(${out_hdr} "${_hdr}" PARENT_SCOPE)
107 SET(${out_dirs} "${_dirs}" PARENT_SCOPE)
110 ## -------------------------------------------------------------------------
112 ## -------------------------------------------------------------------------
113 FUNCTION(cpPlugins_BuildLibrary lib_name lib_type)
116 cpPlugins_PrepareFiles(_src _hdr _dirs ${ARGN})
119 ADD_LIBRARY(${lib_name} ${lib_type} ${_src} ${_hdr})
120 GENERATE_EXPORT_HEADER(
122 BASE_NAME ${lib_name}
123 EXPORT_MACRO_NAME ${lib_name}_EXPORT
124 EXPORT_FILE_NAME ${lib_name}_Export.h
125 STATIC_DEFINE ${lib_name}_BUILT_AS_STATIC
129 ## -------------------------------------------------------------------------
131 ## -------------------------------------------------------------------------
132 FUNCTION(cpPlugins_BuildLibraryFromDirectory lib_name lib_type lib_dir)
134 ${CMAKE_CURRENT_SOURCE_DIR}
135 ${CMAKE_CURRENT_BINARY_DIR}
137 cpPlugins_GetFiles(_files "${lib_dir}/*")
138 cpPlugins_BuildLibrary(${lib_name} ${lib_type} ${_files} ${ARGN})
140 ## -------------------------------------------------------------------------
142 ## -------------------------------------------------------------------------
143 FUNCTION(cpPlugins_BuildApplicationFromDirectory app_name app_dir)
146 cpPlugins_GetFiles(_files "${app_dir}/*")
147 cpPlugins_PrepareFiles(_src _hdr _dirs ${_files})
149 ## -- Guess compilation source
151 IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
152 SET(_app_os_target WIN32)
153 ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
154 SET(_app_os_target MACOSX_BUNDLE)
155 ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
157 ## -- Include directories
158 INCLUDE_DIRECTORIES(${_dirs})
160 ## -- Compile application
161 ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_src} ${_hdr})
164 ## -------------------------------------------------------------------------