## -------------------------------------------------------------------------
FUNCTION(
PrepareSourceFiles
+ out_lib_name
out_sources_list
out_headers_list
out_headers_paths
SET(_headers_extensions .h .hpp .hxx)
SET(_qt_ui_extensions .ui)
SET(_demangler_extensions .d)
+SET(_instances_extensions .i)
## -- Configure inputs
SET(_all_files)
SET(_hdrs)
SET(_qts)
SET(_demanglers)
+SET(_instances)
FOREACH(_file ${_all_files})
GET_FILENAME_COMPONENT(_ext ${_file} EXT)
LIST(FIND _sources_extensions ${_ext} _src)
LIST(FIND _headers_extensions ${_ext} _hdr)
LIST(FIND _qt_ui_extensions ${_ext} _ui)
LIST(FIND _demangler_extensions ${_ext} _dem)
+ LIST(FIND _instances_extensions ${_ext} _ins)
IF(NOT ${_src} EQUAL -1)
LIST(APPEND _srcs ${_file})
ENDIF(NOT ${_src} EQUAL -1)
IF(NOT ${_dem} EQUAL -1)
LIST(APPEND _demanglers ${_file})
ENDIF(NOT ${_dem} EQUAL -1)
+ IF(NOT ${_ins} EQUAL -1)
+ LIST(APPEND _instances ${_file})
+ ENDIF(NOT ${_ins} EQUAL -1)
ENDFOREACH(_file)
# -- Prepare Qt4-based code
LIST(APPEND _hdrs ${_d_out})
ENDFOREACH(_d)
+## -- Create instances
+FOREACH(_i ${_instances})
+ STRING(
+ REPLACE
+ ${PROJECT_SOURCE_DIR}
+ ${PROJECT_BINARY_DIR}
+ _i_bin
+ ${_i}
+ )
+ GET_FILENAME_COMPONENT(_i_path ${_i_bin} DIRECTORY)
+ GET_FILENAME_COMPONENT(_out_name ${_i} NAME_WE)
+
+ ## -- Infere source code filenames
+ MATH(EXPR _last_range "${cpPlugins_CONFIG_NUMBER_OF_FILES}-1")
+ SET(_out_code "${_i_path}/${_out_name}.h")
+ LIST(APPEND _hdrs ${_i_path}/${_out_name}.h)
+ FOREACH(_n RANGE 0 ${_last_range})
+ LIST(APPEND _out_code ${_i_path}/${_out_name}_${_n}.cxx)
+ LIST(APPEND _srcs ${_i_path}/${_out_name}_${_n}.cxx)
+ ENDFOREACH(_n)
+
+ ## -- Command to write source code
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${_out_code}
+ DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_i}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_i_path}
+ COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_i} ${out_lib_name} ${_i_path}/${_out_name}
+ )
+ENDFOREACH(_i)
+
## -- Real compilation
SET(_hdrs_paths)
FOREACH(_hdr ${_hdrs})
lib_name
lib_type
)
-PrepareSourceFiles(_srcs _hdrs _paths ${ARGN})
+PrepareSourceFiles(${lib_name} _srcs _hdrs _paths ${ARGN})
INCLUDE_DIRECTORIES(
${_paths}
${CMAKE_CURRENT_SOURCE_DIR}
CreateLib(${lib_name} ${lib_type} ${_files} ${ARGN})
ENDFUNCTION()
-## -------------------------------------------------------------------------
-FUNCTION(
- CompileInstances
- out_lib_name
- def_file
- number_of_files
- )
-
-### -- Configure inputs to be cmake-path compatible
-SET(_src_dir ${CMAKE_CURRENT_SOURCE_DIR})
-SET(_bin_dir ${CMAKE_CURRENT_BINARY_DIR})
-SET(_def_file "${_src_dir}/${def_file}")
-
-## -- Infere source code filenames
-MATH(EXPR _last_range "${number_of_files}-1")
-SET(_out_code "${_bin_dir}/${out_lib_name}.h")
-FOREACH(_n RANGE 0 ${_last_range})
- LIST(APPEND _out_code ${_bin_dir}/${out_lib_name}_${_n}.cxx)
-ENDFOREACH(_n)
-
-## -- Command to write source code
-ADD_CUSTOM_COMMAND(
- OUTPUT ${_out_code}
- DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_def_file}
- COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_def_file} ${out_lib_name} ${_bin_dir} ${number_of_files}
- )
-
-## -- Create library
-CreateLib(${out_lib_name} SHARED "${_out_code}")
-
-ENDFUNCTION()
-
## -------------------------------------------------------------------------
FUNCTION(
CreatePlugin
lib_name
lib_dir
- number_of_files
)
-
GET_FILENAME_COMPONENT(_lib_dir ${lib_dir} REALPATH)
FILE(GLOB_RECURSE _files "${_lib_dir}/*")
SET(_hdr_to_wrap)
-SET(_instances)
FOREACH(_file ${_files})
FILE(READ ${_file} _txt)
STRING(FIND "${_txt}" "cpPluginsObject" _res)
IF(NOT ${_res} EQUAL -1)
LIST(APPEND _hdr_to_wrap ${_file})
ENDIF(NOT ${_res} EQUAL -1)
- GET_FILENAME_COMPONENT(_ext ${_file} EXT)
- IF(${_ext} STREQUAL ".i")
- LIST(APPEND _instances ${_file})
- ENDIF(${_ext} STREQUAL ".i")
ENDFOREACH(_file)
-IF(_instances)
- FOREACH(_instance ${_instances})
- STRING(
- REPLACE
- ${PROJECT_SOURCE_DIR}
- ${PROJECT_BINARY_DIR}
- _out_dir
- ${_lib_dir}
- )
- MATH(EXPR _last_range "${number_of_files}-1")
- SET(_out_code "${_out_dir}/${lib_name}.h")
- FOREACH(_n RANGE 0 ${_last_range})
- LIST(APPEND _out_code ${_out_dir}/${lib_name}_${_n}.cxx)
- ENDFOREACH(_n)
-
- ADD_CUSTOM_COMMAND(
- OUTPUT ${_out_code}
- DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_instance}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir}
- COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_instance} ${lib_name} ${_out_dir} ${number_of_files}
- )
- LIST(APPEND _files ${_out_code})
- ENDFOREACH(_instance)
-ENDIF(_instances)
-
IF(_hdr_to_wrap)
STRING(
REPLACE
app_name
app_dir
)
-FILE(GLOB_RECURSE _files "${app_dir}/*")
-PrepareSourceFiles(_srcs _hdrs _paths ${_files} ${ARGN})
-INCLUDE_DIRECTORIES(
- ${_paths}
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- )
-IF(_srcs)
- SET(_app_os_target)
- IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- SET(_app_os_target WIN32)
- ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
- SET(_app_os_target MACOSX_BUNDLE)
- ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs})
-ENDIF(_srcs)
+OPTION(BUILD_${app_name} "Build ${app_name}" OFF)
+IF(BUILD_${app_name})
+ FILE(GLOB_RECURSE _files "${app_dir}/*")
+ PrepareSourceFiles(${app_name} _srcs _hdrs _paths ${_files} ${ARGN})
+ INCLUDE_DIRECTORIES(
+ ${_paths}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ IF(_srcs)
+ SET(_app_os_target)
+ IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ SET(_app_os_target WIN32)
+ ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+ SET(_app_os_target MACOSX_BUNDLE)
+ ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs})
+ ENDIF(_srcs)
+ENDIF(BUILD_${app_name})
ENDFUNCTION()
## eof - $RCSfile$