1616# *************************************************************************
1717
1818set (ABCMAKE_VERSION_MAJOR 6)
19- set (ABCMAKE_VERSION_MINOR 0 )
19+ set (ABCMAKE_VERSION_MINOR 1 )
2020set (ABCMAKE_VERSION_PATCH 0)
2121set (ABCMAKE_VERSION "${ABCMAKE_VERSION_MAJOR} .${ABCMAKE_VERSION_MINOR} .${ABCMAKE_VERSION_PATCH} " )
2222
@@ -101,6 +101,8 @@ set(_ABCMAKE_PROP_INSTALL_DIR "INSTALL_DIR") # The directory where the project w
101101set (ABCMAKE_DIRPROP_VERSION "VERSION" ) # The abcmake version of the component
102102set (ABCMAKE_DIRPROP_COMPONENT_NAME "COMPONENT_NAME" ) # The name of the component (local PROJECT_NAME)
103103set (ABCMAKE_DIRPROP_TARGETS "TARGETS" ) # The list of targets built by the component
104+ set (ABCMAKE_DIRPROP_SRC "COMPONENT_SRC" ) # The list of source directories
105+ set (ABCMAKE_DIRPROP_INCLUDE "COMPONENT_INCLUDE" ) # The list of include directories
104106
105107# Default values
106108set (_ABCMAKE_DEFAULT_COMPONENTS_DIR "components" )
@@ -114,23 +116,23 @@ set(_ABCMAKE_DEFAULT_INSTALL_DIR "${CMAKE_BINARY_DIR}/../install")
114116
115117function (_abcmake_set_prop PROPERTY_NAME PROPERTY_VALUE )
116118 set_property (GLOBAL PROPERTY
117- ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} ${PROPERTY_VALUE} )
119+ " ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} " " ${PROPERTY_VALUE} " )
118120endfunction ()
119121
120122function (_abcmake_append_prop PROPERTY_NAME PROPERTY_VALUE )
121123 set_property (GLOBAL APPEND PROPERTY
122- ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} ${PROPERTY_VALUE} )
124+ " ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} " " ${PROPERTY_VALUE} " )
123125endfunction ()
124126
125127function (_abcmake_set_prop_curdir PROPERTY_NAME PROPERTY_VALUE )
126128 set_directory_properties (PROPERTIES
127- ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} ${PROPERTY_VALUE} )
129+ " ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} " " ${PROPERTY_VALUE} " )
128130endfunction ()
129131
130132function (_abcmake_append_prop_curdir PROPERTY_NAME PROPERTY_VALUE )
131133 set_property (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
132134 APPEND PROPERTY
133- ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} ${PROPERTY_VALUE} )
135+ " ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} " " ${PROPERTY_VALUE} " )
134136endfunction ()
135137
136138
@@ -162,6 +164,7 @@ function(_abcmake_get_prop PROPERTY_NAME OUT_VAR_NAME)
162164endfunction ()
163165
164166function (_abcmake_get_prop_dir DIRECTORY PROPERTY_NAME OUT_VAR_NAME )
167+ message (DEBUG "[_abcmake_get_prop_dir] Getting property ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} from ${DIRECTORY} " )
165168 get_directory_property (tmp_result DIRECTORY ${DIRECTORY}
166169 ${ABCMAKE_PROPERTY_PREFIX}${PROPERTY_NAME} )
167170 set (${OUT_VAR_NAME} ${tmp_result} PARENT_SCOPE )
@@ -206,7 +209,7 @@ function(_abcmake_add_subdirectory PATH)
206209
207210 # ABCMAKE_ADDED_PROJECTS is an interface, it may break compatibility if changed!
208211 _abcmake_get_prop (${ABCMAKE_PROP_ADDED_PROJECTS} projects )
209- message (DEBUG "Added projects: ${projects} " )
212+ message (DEBUG "[_abcmake_add_subdirectory] Added projects: ${projects} " )
210213
211214 # Resolve relative path
212215 get_filename_component (PATH "${PATH} " ABSOLUTE )
@@ -217,7 +220,7 @@ function(_abcmake_add_subdirectory PATH)
217220
218221 # Use the last directory name for a binary directory name
219222 get_filename_component (last_dir "${PATH} " NAME )
220- add_subdirectory (${PATH} abc_${last_dir} )
223+ add_subdirectory (${PATH} abc_${last_dir} EXCLUDE_FROM_ALL )
221224 endif ()
222225
223226endfunction ()
@@ -233,7 +236,7 @@ function(_abcmake_add_project PATH OUT_ABCMAKE_VER)
233236 return ()
234237 endif ()
235238
236- message (DEBUG "Adding project ${PATH} " )
239+ message (DEBUG "[_abcmake_add_project] Adding project ${PATH} " )
237240 _abcmake_add_subdirectory (${PATH} )
238241
239242 _abcmake_get_prop_dir (${PATH} "VERSION" version )
@@ -255,7 +258,7 @@ endfunction()
255258# add_component.cmake ==========================================================
256259
257260include (CMakeParseArguments )
258- set (ABC_INSTALL_LIB_SUBDIR "lib " )
261+ set (ABC_INSTALL_LIB_SUBDIR ". " )
259262set (ABC_INSTALL_EXE_SUBDIR "." )
260263
261264# Add all projects from the components subdirectory
@@ -284,7 +287,7 @@ endfunction()
284287# @param TARGETNAME - name of the target to add sources
285288function (target_sources_directory TARGETNAME SOURCE_DIR )
286289 file (GLOB_RECURSE SOURCES "${SOURCE_DIR} /*.cpp" "${SOURCE_DIR} /*.c" )
287- message ( DEBUG "${TARGETNAME} sources: ${SOURCES} " )
290+ message ( DEBUG "[target_sources_directory] ${TARGETNAME} sources: ${SOURCES} " )
288291 target_sources (${TARGETNAME} PRIVATE ${SOURCES} )
289292endfunction ()
290293
@@ -296,7 +299,14 @@ function(_abcmake_target_install TARGETNAME DESTINATION)
296299 _abcmake_get_install (install_dir )
297300 set (CMAKE_INSTALL_PREFIX ${install_dir}
298301 CACHE PATH "default install path" FORCE )
302+ message (DEBUG "[_abcmake_target_install] Install target: ${TARGETNAME} " )
299303 install (TARGETS ${TARGETNAME} DESTINATION ${DESTINATION} )
304+
305+ # install include directories
306+ _abcmake_get_prop_dir (${CMAKE_CURRENT_SOURCE_DIR} ${ABCMAKE_DIRPROP_INCLUDE} include_dir )
307+ message (DEBUG "[_abcmake_target_install] Install include: ${include_dir} " )
308+ install (DIRECTORY ${include_dir} DESTINATION ${DESTINATION} )
309+
300310endfunction ()
301311
302312
@@ -322,11 +332,11 @@ function(_abcmake_target_init TARGETNAME)
322332 cmake_parse_arguments (arg "${flags} " "${args} " "${listArgs} " ${ARGN} )
323333
324334 if (NOT arg_SOURCE_DIR )
325- set (arg_SOURCE_DIR "src" )
335+ set (arg_SOURCE_DIR "src" ) # TODO: replace with _abcmake_get_src?
326336 endif ()
327337
328338 if (NOT arg_INCLUDE_DIR)
329- set (arg_INCLUDE_DIR "include" )
339+ set (arg_INCLUDE_DIR "include" ) # TODO: replace with _abcmake_get_include?
330340 endif ()
331341
332342 _abcmake_count_parents (parents_num )
@@ -371,8 +381,21 @@ function(add_main_component TARGETNAME)
371381
372382 if (NOT arg_INCLUDE_DIR)
373383 _abcmake_get_include (arg_INCLUDE_DIR )
384+ if (EXISTS "include" )
385+ set (arg_INCLUDE_DIR "include" )
386+ else ()
387+ set (arg_INCLUDE_DIR "" )
388+ endif ()
374389 endif ()
375390
391+ message (DEBUG "[add_main_component] TARGETNAME: ${TARGETNAME} " )
392+ message (DEBUG "[add_main_component] INCLUDE_DIR: ${arg_INCLUDE_DIR} " )
393+ message (DEBUG "[add_main_component] SOURCE_DIR: ${arg_SOURCE_DIR} " )
394+
395+ # Set Component Src and Include
396+ _abcmake_set_prop_curdir ("${ABCMAKE_DIRPROP_SRC} " "${arg_SOURCE_DIR} " )
397+ _abcmake_set_prop_curdir ("${ABCMAKE_DIRPROP_INCLUDE} " "${arg_INCLUDE_DIR} " )
398+
376399 add_executable (${TARGETNAME} )
377400 _abcmake_target_init (${TARGETNAME}
378401 INCLUDE_DIR ${arg_INCLUDE_DIR}
@@ -390,14 +413,18 @@ function(add_component TARGETNAME)
390413 set (args)
391414 set (listArgs INCLUDE_DIR SOURCE_DIR)
392415 cmake_parse_arguments (arg "${flags} " "${args} " "${listArgs} " ${ARGN} )
393- message (DEBUG "add_component: ${TARGETNAME} " )
394-
416+
395417 if (NOT arg_SOURCE_DIR )
396418 _abcmake_get_src (arg_SOURCE_DIR )
397419 endif ()
398420
399421 if (NOT arg_INCLUDE_DIR)
400422 _abcmake_get_include (arg_INCLUDE_DIR )
423+ if (EXISTS "include" )
424+ set (arg_INCLUDE_DIR "include" )
425+ else ()
426+ set (arg_INCLUDE_DIR "" )
427+ endif ()
401428 endif ()
402429
403430 if (arg_SHARED)
@@ -406,6 +433,15 @@ function(add_component TARGETNAME)
406433 add_library (${TARGETNAME} STATIC )
407434 endif ()
408435
436+ message (DEBUG "[add_component] TARGETNAME: ${TARGETNAME} " )
437+ message (DEBUG "[add_component] INCLUDE_DIR: ${arg_INCLUDE_DIR} " )
438+ message (DEBUG "[add_component] SOURCE_DIR: ${arg_SOURCE_DIR} " )
439+ message (DEBUG "[add_component] SHARED: ${arg_SHARED} " )
440+
441+ # Set Component Src and Include
442+ _abcmake_set_prop_curdir ("${ABCMAKE_DIRPROP_SRC} " "${arg_SOURCE_DIR} " )
443+ _abcmake_set_prop_curdir ("${ABCMAKE_DIRPROP_INCLUDE} " "${arg_INCLUDE_DIR} " )
444+
409445 _abcmake_target_init (${TARGETNAME}
410446 INCLUDE_DIR ${arg_INCLUDE_DIR}
411447 SOURCE_DIR ${arg_SOURCE_DIR} )
@@ -426,7 +462,7 @@ set(__ABCMAKE_COMPONENT_REGISTRY_SEPARATOR "::::")
426462function (register_components PATH )
427463
428464 foreach (path ${ARGV} )
429- message (DEBUG " 📂 Path: ${path} " )
465+ message (DEBUG "[register_components] 📂 Path: ${path} " )
430466 _abcmake_add_project (${path} PROJECT_ABCMAKE_VER )
431467 if (PROJECT_ABCMAKE_VER)
432468 _abcmake_get_prop_dir (${path} ${ABCMAKE_DIRPROP_COMPONENT_NAME} component_name )
@@ -458,7 +494,7 @@ endfunction()
458494# Gets the path of a component from the registry. Returns null if not found.
459495function (_abcmake_get_from_registry COMPONENT_NAME OUT_PATH )
460496 _abcmake_get_prop (${ABCMAKE_PROP_COMPONENT_REGISTRY} registry )
461- message (DEBUG "Get ${COMPONENT_NAME} from : ${registry} " )
497+ message (DEBUG "[_abcmake_get_from_registry] Get ${COMPONENT_NAME} from : ${registry} " )
462498 foreach (entry ${registry} )
463499 _split_component_entry (${entry} name path )
464500 if (name STREQUAL COMPONENT_NAME)
@@ -508,8 +544,8 @@ function (_abcmake_target_link_components PROCESS_LEVEL TARGETNAME)
508544 set (listArgs PATH NAME)
509545 cmake_parse_arguments (arg "${flags} " "${args} " "${listArgs} " ${ARGN} )
510546
511- message (DEBUG "_abcmake_target_link_components arg_PATH: ${arg_PATH} " )
512- message (DEBUG "_abcmake_target_link_components arg_NAME: ${arg_NAME} " )
547+ message (DEBUG "[ _abcmake_target_link_components] arg_PATH: ${arg_PATH} " )
548+ message (DEBUG "[ _abcmake_target_link_components] arg_NAME: ${arg_NAME} " )
513549
514550 # Link components by path
515551 foreach (PATH ${arg_PATH} )
0 commit comments