[DEV] update gld interpreatation

This commit is contained in:
Edouard DUPIN 2021-11-10 23:50:26 +01:00
parent 21eb62613d
commit 5555a74aa4
6 changed files with 963 additions and 441 deletions

View File

@ -1,210 +1,8 @@
cmake_minimum_required(VERSION 3.20)
if (WIN32)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
endif()
set(CPACK_VERBATIM_VARIABLES YES)
include(CPack)
## fist step is determining the target:
if (WIN32)
set(GLD_TARGET "Windows" CACHE INTERNAL "")
elseif(APPLE)
set(GLD_TARGET "MacOs" CACHE INTERNAL "")
elseif(LINUX)
set(GLD_TARGET "Linux" CACHE INTERNAL "")
elseif(UNIX AND NOT APPLE)
set(GLD_TARGET "Linux" CACHE INTERNAL "")
else()
message("GLD Can not determine the target !!!")
exit(-1)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(GLD_COMPILATOR "clang" CACHE INTERNAL "")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(GLD_COMPILATOR "gcc" CACHE INTERNAL "")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(GLD_COMPILATOR "intel" CACHE INTERNAL "")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(GLD_COMPILATOR "msvc" CACHE INTERNAL "")
else()
message("GLD Can not determine the compilator !!!")
exit(-1)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(GLD_MODE "debug" CACHE INTERNAL "")
elseif(CMAKE_BUILD_TYPE STREQUAL "debug")
set(GLD_MODE "debug" CACHE INTERNAL "")
else()
set(GLD_MODE "release" CACHE INTERNAL "")
endif()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
set(GLD_ARCH "x86" CACHE INTERNAL "")
set(GLD_BUS_SIZE "64" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
set(GLD_ARCH "x86" CACHE INTERNAL "")
set(GLD_BUS_SIZE "32" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64")
set(GLD_ARCH "ppc" CACHE INTERNAL "")
set(GLD_BUS_SIZE "64" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc")
set(GLD_ARCH "ppc" CACHE INTERNAL "")
set(GLD_BUS_SIZE "32" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(GLD_ARCH "arm" CACHE INTERNAL "")
set(GLD_BUS_SIZE "64" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "armv9")
set(GLD_ARCH "arm" CACHE INTERNAL "")
set(GLD_BUS_SIZE "32" CACHE INTERNAL "")
else()
message("GLD Can not determine the architecture and bus-size !!!")
exit(-1)
endif()
# cmake does not support other mode than "intricate" the "isolate" mode is too much complicated to do.
set(GLD_SANITY_MODE "intricate" CACHE INTERNAL "")
# list of current supported language:
# - 'c': C language
# - 'c++': C++ language
# - 'asm': asembler language
# - 'm': Objective-C language
# - 'mm': Objective-C++ language
# - 'java': Java language
# - 'javah': generated c header with Java description (for JNI)
# TODO: maybe permit user to add some other... like "in", "masm", or other pre-step generation code???
set(GLD_SUPPORT_LANGUAGE "c;asm;c++;m;mm;java;javah" CACHE INTERNAL "")
set(GLD_SUPPORT_LANGUAGE_VARIABLE "C;ASM;CXX;M;MM;JAVA;JAVAH" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_C "c;C" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_CXX "cpp;CPP;cxx;CXX" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_ASM "s;S" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_M "m;M" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_MM "mm;MM" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_JAVA "java" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_JAVAH "javah" CACHE INTERNAL "")
# where is build the module
set(GLD_GLOBAL_BUILD_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${GLD_TARGET}_${GLD_ARCH}_${GLD_BUS_SIZE}/${GLD_MODE}/build/${GLD_COMPILATOR}/" CACHE INTERNAL "")
# where the package is prepared
set(GLD_GLOBAL_STAGING_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${GLD_TARGET}_${GLD_ARCH}_${GLD_BUS_SIZE}/${GLD_MODE}/staging/${GLD_COMPILATOR}/" CACHE INTERNAL "")
# whe the bundle (tar, jar ...) is set
set(GLD_GLOBAL_FINAL_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${GLD_TARGET}_${GLD_ARCH}_${GLD_BUS_SIZE}/${GLD_MODE}/final/${GLD_COMPILATOR}/" CACHE INTERNAL "")
message("Global GLD properties:")
message(" GLD_MODE : ${GLD_MODE}")
message(" GLD_COMPILATOR : ${GLD_COMPILATOR}")
message(" GLD_TARGET : ${GLD_TARGET}")
message(" GLD_ARCH : ${GLD_ARCH}")
message(" GLD_BUS_SIZE : ${GLD_BUS_SIZE}")
message(" GLD_SANITY_MODE : ${GLD_SANITY_MODE}")
message(" GLD_GLOBAL_BUILD_FOLDER : ${GLD_GLOBAL_BUILD_FOLDER}")
message(" GLD_GLOBAL_STAGING_FOLDER : ${GLD_GLOBAL_STAGING_FOLDER}")
message(" GLD_GLOBAL_FINAL_FOLDER : ${GLD_GLOBAL_FINAL_FOLDER}")
##
## @brief get the type of a variable
## @param[in] INPUT_JSON Json data.
## @param[in] VARIABLE Name of the variable.
## @param[out] OUT_VAR Retrun type of the node: NULL, NUMBER, STRING, BOOLEAN, ARRAY, OBJECT or NOTFOUND (if does not exist)
##
function(json_get_type OUT_VAR INPUT_JSON VARIABLE)
string(JSON VALUE ERROR_VARIABLE ${VARIABLE} TYPE ${INPUT_JSON} ${VARIABLE})
if (${VALUE} STREQUAL ${VARIABLE}-NOTFOUND)
set(${OUT_VAR} "NOTFOUND" PARENT_SCOPE)
else()
set(${OUT_VAR} "${VALUE}" PARENT_SCOPE)
endif()
endfunction()
function(json_size OUT_VAR INPUT_JSON VARIABLE)
string(JSON VALUE ERROR_VARIABLE ${VARIABLE} LENGTH ${INPUT_JSON} ${VARIABLE})
if (${VALUE} STREQUAL ${VARIABLE}-NOTFOUND)
set("${OUT_VAR}" 0 PARENT_SCOPE)
else ()
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endif()
endfunction()
function(json_get_data OUT_VAR INPUT_JSON VARIABLE)
string(JSON VALUE GET ${INPUT_JSON} ${VARIABLE})
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endfunction()
function(json_object_key OUT_VAR INPUT_JSON IDX)
string(JSON VALUE MEMBER ${INPUT_JSON} ${IDX})
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endfunction()
function(json_object_keys OUT_VAR MY_JSON_STRING VARIABLE)
json_size(SIZE ${MY_JSON_STRING} ${VARIABLE})
#message("target SIZE = ${SIZE}")
json_get_data(OBJECT_DATA ${MY_JSON_STRING} ${VARIABLE})
MATH(EXPR SIZE "${SIZE}-1")
set(OUT "")
foreach(IDX RANGE ${SIZE})
json_object_key(ELEMENT ${OBJECT_DATA} ${IDX})
#message(" - : ${ELEMENT}")
list(APPEND OUT ${ELEMENT})
endforeach()
set("${OUT_VAR}" ${OUT} PARENT_SCOPE)
endfunction()
function(json_object_values OUT_VAR INPUT_JSON VARIABLE KEYS)
string(JSON VALUE GET ${INPUT_JSON} ${VARIABLE} ${KEYS})
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endfunction()
function(json_get_list OUT_VAR INPUT_JSON VARIABLE)
string(JSON LIST_JSON_ELEMENTS ERROR_VARIABLE ${VARIABLE} GET ${INPUT_JSON} ${VARIABLE})
if (${LIST_JSON_ELEMENTS} STREQUAL ${VARIABLE}-NOTFOUND)
set("${OUT_VAR}" PARENT_SCOPE)
retrun()
endif()
#message("LIST_JSON_ELEMENTS : ${LIST_JSON_ELEMENTS}")
string(JSON LENGTH_VALUE LENGTH ${LIST_JSON_ELEMENTS})
#message("LENGTH_VALUE : ${LENGTH_VALUE}")
if (${LENGTH_VALUE} EQUAL 0)
set("${OUT_VAR}" PARENT_SCOPE)
retrun()
endif()
set(OUT_LIST)
MATH(EXPR LENGTH_VALUE "${LENGTH_VALUE}-1")
foreach(IDX RANGE ${LENGTH_VALUE})
string(JSON ELEM GET ${LIST_JSON_ELEMENTS} ${IDX})
#message(" - : ${ELEM}")
list(APPEND OUT_LIST ${ELEM})
endforeach()
#message("OUT_LIST : ${OUT_LIST}")
set("${OUT_VAR}" ${OUT_LIST} PARENT_SCOPE)
endfunction()
function(json_get_element OUT_VAR INPUT_JSON VARIABLE)
string(JSON ELEMENT ERROR_VARIABLE ${VARIABLE} GET ${INPUT_JSON} ${VARIABLE})
if ("${ELEMENT}" STREQUAL "${VARIABLE}-NOTFOUND")
set("${OUT_VAR}" "" PARENT_SCOPE)
elseif ("${ELEMENT}" STREQUAL "NOTFOUND")
set("${OUT_VAR}" "" PARENT_SCOPE)
else()
set("${OUT_VAR}" ${ELEMENT} PARENT_SCOPE)
endif()
endfunction()
include("cmake/GLDJson.cmake")
include("cmake/GLDTargetConfig.cmake")
include("cmake/GLDTools.cmake")
function(GLD_import_full_group NAME_GLD_MODULE MY_JSON_STRING ELEMENT_TO_CHECK TYPE_VARIABLE)
json_get_type(TYPE ${MY_JSON_STRING} ${ELEMENT_TO_CHECK})
@ -245,47 +43,49 @@ function(GLD_import_element_dependency NAME_GLD_MODULE MY_JSON_STRING)
if (${TYPE} STREQUAL "ARRAY")
json_size(SIZE ${MY_JSON_STRING} "dependency")
#message("Dependency SIZE = ${SIZE}")
json_get_data(OBJECT_DATA ${MY_JSON_STRING} "dependency")
MATH(EXPR SIZE "${SIZE}-1")
set(VAR_OUT_TMP "")
foreach(IDX RANGE ${SIZE})
json_get_data(ELEMENT ${OBJECT_DATA} ${IDX})
json_get_type(TYPE ${OBJECT_DATA} ${IDX})
if (${TYPE} STREQUAL "STRING")
message(" - <dep> : ${ELEMENT}")
list(APPEND VAR_OUT_TMP ${ELEMENT})
elseif (${TYPE} STREQUAL "OBJECT")
json_get_type(TYPE ${ELEMENT} "name")
if (SIZE GREATER 0)
json_get_data(OBJECT_DATA ${MY_JSON_STRING} "dependency")
MATH(EXPR SIZE "${SIZE}-1")
set(VAR_OUT_TMP "")
foreach(IDX RANGE ${SIZE})
json_get_data(ELEMENT ${OBJECT_DATA} ${IDX})
json_get_type(TYPE ${OBJECT_DATA} ${IDX})
if (${TYPE} STREQUAL "STRING")
json_get_data(DEPENDENCY_NAME ${ELEMENT} "name")
json_get_type(TYPE ${ELEMENT} "optional")
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
if (${TYPE} STREQUAL "BOOLEAN")
json_get_data(DEPENDENCY_OPTIONAL ${ELEMENT} "optional")
if (${DEPENDENCY_OPTIONAL})
message(" - <dep> : ${DEPENDENCY_NAME} (optional) ==> not managed now ...")
#message("optional value ==========================> '${DEPENDENCY_OPTIONAL}' ==> MAYBE")
list(APPEND LIST_OPTIONAL_VALUE ${DEPENDENCY_NAME})
message(" - <dep> : ${ELEMENT}")
list(APPEND VAR_OUT_TMP ${ELEMENT})
elseif (${TYPE} STREQUAL "OBJECT")
json_get_type(TYPE ${ELEMENT} "name")
if (${TYPE} STREQUAL "STRING")
json_get_data(DEPENDENCY_NAME ${ELEMENT} "name")
json_get_type(TYPE ${ELEMENT} "optional")
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
if (${TYPE} STREQUAL "BOOLEAN")
json_get_data(DEPENDENCY_OPTIONAL ${ELEMENT} "optional")
if (${DEPENDENCY_OPTIONAL})
message(" - <dep> : ${DEPENDENCY_NAME} (optional) ==> not managed now ...")
#message("optional value ==========================> '${DEPENDENCY_OPTIONAL}' ==> MAYBE")
list(APPEND LIST_OPTIONAL_VALUE ${DEPENDENCY_NAME})
else()
message(" - <dep> : ${DEPENDENCY_NAME}")
#message("optional value ==========================> '${DEPENDENCY_OPTIONAL}' ==> MUST")
list(APPEND VAR_OUT_TMP ${DEPENDENCY_NAME})
endif()
else()
message(" - <dep> : ${DEPENDENCY_NAME}")
#message("optional value ==========================> '${DEPENDENCY_OPTIONAL}' ==> MUST")
list(APPEND VAR_OUT_TMP ${DEPENDENCY_NAME})
endif()
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
else()
message(" - <dep> : ${DEPENDENCY_NAME}")
list(APPEND VAR_OUT_TMP ${DEPENDENCY_NAME})
message("Dependency 'name' is not a string or is missing type: ${TYPE}")
endif()
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
else()
message("Dependency 'name' is not a string or is missing type: ${TYPE}")
message("dependency element not manage data : ${ELEMENT}")
## TODO add in dependency if optional : check if the element exit in the current module list ...
endif()
else()
message("dependency element not manage data : ${ELEMENT}")
## TODO add in dependency if optional : check if the element exit in the current module list ...
endif()
endforeach()
list(APPEND LIST_VALUE ${VAR_OUT_TMP})
endforeach()
list(APPEND LIST_VALUE ${VAR_OUT_TMP})
endif()
elseif(${TYPE} STREQUAL "NOTFOUND")
return()
endif()
@ -308,33 +108,36 @@ function(GLD_import_element_source NAME_GLD_MODULE MY_JSON_STRING)
json_get_data(OBJECT_DATA ${MY_JSON_STRING} "source")
json_size(SIZE ${MY_JSON_STRING} "source")
#message("Dependency SIZE = ${SIZE}")
MATH(EXPR SIZE "${SIZE}-1")
set(VAR_OUT_TMP "")
foreach(IDX RANGE ${SIZE})
json_get_data(ELEMENT ${OBJECT_DATA} ${IDX})
json_get_type(TYPE ${OBJECT_DATA} ${IDX})
if (${TYPE} STREQUAL "STRING")
message(" - <src> : ${ELEMENT}")
list(APPEND LIST_VALUE ${ELEMENT})
elseif (${TYPE} STREQUAL "OBJECT")
json_get_type(TYPE ${ELEMENT} "source")
json_get_data(ELEMENT_SOURCE ${ELEMENT} "source")
if (SIZE GREATER 0)
MATH(EXPR SIZE "${SIZE}-1")
set(VAR_OUT_TMP "")
foreach(IDX RANGE ${SIZE})
json_get_data(ELEMENT ${OBJECT_DATA} ${IDX})
json_get_type(TYPE ${OBJECT_DATA} ${IDX})
if (${TYPE} STREQUAL "STRING")
message(" - <src> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
elseif (${TYPE} STREQUAL "ARRAY")
message(" - <src> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
message(" - <src> : ${ELEMENT}")
list(APPEND LIST_VALUE ${ELEMENT})
elseif (${TYPE} STREQUAL "OBJECT")
message(" - <src2> : ${ELEMENT}")
json_get_type(TYPE ${ELEMENT} "source")
json_get_data(ELEMENT_SOURCE ${ELEMENT} "source")
if (${TYPE} STREQUAL "STRING")
message(" - <src> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
elseif (${TYPE} STREQUAL "ARRAY")
message(" - <src> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
else()
message("Dependency 'name' is not a string or is missing type: ${TYPE}")
endif()
# TODO: add the source specific flags or other things ...
else()
message("Dependency 'name' is not a string or is missing type: ${TYPE}")
message("'source' element not manage data : ${ELEMENT}")
## TODO add in dependency if optional : check if the element exit in the current module list ...
endif()
# TODO: add the source specific flags or other things ...
else()
message("'source' element not manage data : ${ELEMENT}")
## TODO add in dependency if optional : check if the element exit in the current module list ...
endif()
endforeach()
endforeach()
endif()
elseif (${TYPE} STREQUAL "OBJECT")
# todo: manage object with source like { "c++":[...]...}
elseif(${TYPE} STREQUAL "NOTFOUND")
@ -360,33 +163,63 @@ function(GLD_import_element_header NAME_GLD_MODULE MY_JSON_STRING)
json_get_data(OBJECT_DATA ${MY_JSON_STRING} "header")
json_size(SIZE ${MY_JSON_STRING} "header")
#message("Dependency SIZE = ${SIZE}")
MATH(EXPR SIZE "${SIZE}-1")
set(VAR_OUT_TMP "")
foreach(IDX RANGE ${SIZE})
json_get_data(ELEMENT ${OBJECT_DATA} ${IDX})
json_get_type(TYPE ${OBJECT_DATA} ${IDX})
if (${TYPE} STREQUAL "STRING")
message(" - <header> : ${ELEMENT}")
list(APPEND LIST_VALUE ${ELEMENT})
elseif (${TYPE} STREQUAL "OBJECT")
json_get_type(TYPE ${ELEMENT} "source")
json_get_data(ELEMENT_SOURCE ${ELEMENT} "source")
if (SIZE GREATER 0)
MATH(EXPR SIZE "${SIZE}-1")
set(VAR_OUT_TMP "")
foreach(IDX RANGE ${SIZE})
json_get_data(ELEMENT ${OBJECT_DATA} ${IDX})
json_get_type(TYPE ${OBJECT_DATA} ${IDX})
if (${TYPE} STREQUAL "STRING")
message(" - <header> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
elseif (${TYPE} STREQUAL "ARRAY")
message(" - <header> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
message(" - <header> : ${ELEMENT}")
list(APPEND LIST_VALUE ${ELEMENT})
elseif (${TYPE} STREQUAL "OBJECT")
json_get_type(TYPE ${ELEMENT} "source")
if (${TYPE} STREQUAL "NOTFOUND")
json_get_type(TYPE ${ELEMENT} "path")
if (${TYPE} STREQUAL "STRING")
json_get_data(ELEMENT_PATH ${ELEMENT} "path")
json_get_data_or_default(ELEMENT_FILTER ${ELEMENT} "filter" "*")
json_get_data_or_default(ELEMENT_RECURSIVE ${ELEMENT} "path" OFF)
json_get_data_or_default(ELEMENT_TO ${ELEMENT} "to" "")
find_all_files(ALL_HEADER_FILES "${MODULE_MAP_${LOCAL_MODULE_NAME}_FOLDER}/${ELEMENT_PATH}" "${ELEMENT_FILTER}" 50)
#message("***********************************************************************")
#foreach(III ${ALL_HEADER_FILES})
# message(" ==> ${III}")
#endforeach()
#message("STATIC_PART = ${MODULE_MAP_${LOCAL_MODULE_NAME}_FOLDER}/${STATIC_PART}")
replace_base_path(ALL_HEADER_FILES_2 "${MODULE_MAP_${LOCAL_MODULE_NAME}_FOLDER}/${ELEMENT_PATH}" "${ALL_HEADER_FILES}")
#message("***********************************************************************")
set(ALL_HEADER_FILES "")
foreach(III ${ALL_HEADER_FILES_2})
#message(" ==> ${III}!${ELEMENT_PATH}:${ELEMENT_TO}")
list(APPEND ALL_HEADER_FILES "${III}!${ELEMENT_PATH}:${ELEMENT_TO}")
endforeach()
list(APPEND LIST_VALUE ${ALL_HEADER_FILES})
else()
message("Dependency 'path' is not a string or is missing type: ${TYPE} : STRING ...")
endif()
else()
if (${TYPE} STREQUAL "STRING")
json_get_data(ELEMENT_SOURCE ${ELEMENT} "source")
message(" - <header> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
#message("optional type = ${TYPE} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ${DEPENDENCY_NAME}")
elseif (${TYPE} STREQUAL "ARRAY")
json_get_data(ELEMENT_SOURCE ${ELEMENT} "source")
message(" - <header> : ${ELEMENT_SOURCE}")
list(APPEND LIST_VALUE ${ELEMENT_SOURCE})
else()
message("Dependency 'source' is not a string or is missing type: ${TYPE} : STRING or ARRAY ...")
endif()
endif()
# TODO: add the source specific flags or other things ...
else()
message("Dependency 'name' is not a string or is missing type: ${TYPE}")
message("'header' element not manage data : ${ELEMENT}")
## TODO add in dependency if optional : check if the element exit in the current module list ...
endif()
# TODO: add the source specific flags or other things ...
else()
message("'header' element not manage data : ${ELEMENT}")
## TODO add in dependency if optional : check if the element exit in the current module list ...
endif()
endforeach()
endforeach()
endif()
elseif (${TYPE} STREQUAL "OBJECT")
json_get_data(OBJECT_DATA ${MY_JSON_STRING} "header")
# todo: manage object with source like { "c++":[...]...}
@ -476,7 +309,7 @@ function(GLD_import_full NAME_GLD_MODULE MY_JSON_STRING)
GLD_import_full_group(${NAME_GLD_MODULE} ${MY_JSON_STRING} "bus-size" ${GLD_BUS_SIZE})
GLD_import_full_group(${NAME_GLD_MODULE} ${MY_JSON_STRING} "compilator" ${GLD_COMPILATOR})
GLD_import_full_group(${NAME_GLD_MODULE} ${MY_JSON_STRING} "compiler" ${GLD_COMPILER})
GLD_import_full_group(${NAME_GLD_MODULE} ${MY_JSON_STRING} "sanity-compilation" ${GLD_SANITY_MODE})
@ -496,6 +329,33 @@ function(GLD_load_from_file_if_needed VAR_OUT LIBRARY_PATH ELEMENT)
endif()
endfunction()
function(GLD_get_import_folder VAR_OUT NAME_GLD_MODULE)
set(LIST_OUT "")
set(${VAR_OUT} "${LIST_OUT}" PARENT_SCOPE)
endfunction()
function(GLD_get_import_folder VAR_OUT NAME_GLD_MODULE)
set(LIST_OUT "")
set(${VAR_OUT} "${LIST_OUT}" PARENT_SCOPE)
endfunction()
function(GLD_get_project_dependency VAR_OUT NAME_GLD_MODULE DEPENDENCY)
GLD_get_module_name(LOCAL_MODULE_NAME ${NAME_GLD_MODULE})
set(LIST_OUT "")
if (DEPENDENCY)
foreach(III "${DEPENDENCY}")
GLD_get_module_name(TMP_MODULE_NAME ${III})
list(APPEND LIST_OUT ${III})
endforeach()
endif()
set(${VAR_OUT} "${LIST_OUT}" PARENT_SCOPE)
endfunction()
function(GLD_import NAME_GLD_MODULE)
GLD_get_module_name(LOCAL_MODULE_NAME ${NAME_GLD_MODULE})
@ -556,6 +416,8 @@ function(GLD_import NAME_GLD_MODULE)
project(${LIBRARY_NAME222})
endif()
set(MODULE_MAP_${LOCAL_MODULE_NAME}_INCLUDE_LOCAL "" CACHE INTERNAL "")
# TODO : Remove if no element in header...
@ -587,96 +449,117 @@ function(GLD_import NAME_GLD_MODULE)
message(" _SOURCE : ${MODULE_MAP_${LOCAL_MODULE_NAME}_SOURCE}")
message(" _HEADER : ${MODULE_MAP_${LOCAL_MODULE_NAME}_HEADER}")
GLD_get_project_dependency(LIST_PROJECT_DEPENDENCY ${NAME_GLD_MODULE} "${MODULE_MAP_${LOCAL_MODULE_NAME}_DEPENDENCY}")
message("===> dep = ${LIST_PROJECT_DEPENDENCY}")
set(TMP_LIST "")
foreach(III ${MODULE_MAP_${LOCAL_MODULE_NAME}_SOURCE})
get_filename_component(BASE_FOLDER ${MODULE_MAP_${LOCAL_MODULE_NAME}_FOLDER}/${III} ABSOLUTE)
list(APPEND TMP_LIST "${BASE_FOLDER}")
endforeach()
add_library(${LIBRARY_NAME222}_OBJ OBJECT ${TMP_LIST})
# allow relocation code for shared library:
set_property(TARGET ${LIBRARY_NAME222}_OBJ PROPERTY POSITION_INDEPENDENT_CODE 1)
set(HAS_DATA_TO_BUILD OFF)
if(TMP_LIST)
set(HAS_DATA_TO_BUILD ON)
add_library(${LIBRARY_NAME222}_OBJ OBJECT ${TMP_LIST})
# allow relocation code for shared library:
set_property(TARGET ${LIBRARY_NAME222}_OBJ PROPERTY POSITION_INDEPENDENT_CODE 1)
endif()
foreach(III ${MODULE_MAP_${LOCAL_MODULE_NAME}_HEADER})
configure_file(${MODULE_MAP_${LOCAL_MODULE_NAME}_FOLDER}/${III} ${MODULE_MAP_${LOCAL_MODULE_NAME}_INCLUDE_PUBLIC}/${III} COPYONLY)
endforeach()
set(TMP_LIST ${MODULE_MAP_${LOCAL_MODULE_NAME}_INCLUDE_LOCAL})
list(APPEND TMP_LIST ${MODULE_MAP_${LOCAL_MODULE_NAME}_INCLUDE_PUBLIC})
target_include_directories(${LIBRARY_NAME222}_OBJ PUBLIC "${TMP_LIST}")
add_library(${LIBRARY_NAME222}_dynamic SHARED $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
add_library(${LIBRARY_NAME222}_static STATIC $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
if ("${GLD_TARGET}" STREQUAL "Windows")
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
# static will keep the element static at the end (the windows architecture fore shared object need to have a static library to access to the DLL ==> create a conflict!!!
else()
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
set_target_properties(${LIBRARY_NAME222}_static PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
endif()
if (LIBRARY_VERSION)
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES VERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES SOVERSION ${LIBRARY_VERSION})
endif()
if (LIBRARY_DECRIPTION)
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES DESCRIPTION ${LIBRARY_DECRIPTION})
endif()
# install dynamic & static library
install(TARGETS ${LIBRARY_NAME222}_dynamic EXPORT ${LIBRARY_NAME222}Targets
RUNTIME DESTINATION ${MODULE_MAP_${LOCAL_MODULE_NAME}_LIB_PATH}
)
install(TARGETS ${LIBRARY_NAME222}_static
RUNTIME DESTINATION ${MODULE_MAP_${LOCAL_MODULE_NAME}_LIB_PATH})
#install(TARGETS ${LIBRARY_NAME222} EXPORT ${LIBRARY_NAME222}Targets
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# RUNTIME DESTINATION bin
# INCLUDES DESTINATION include
#)
# install exported headers
# this copy all the headers in a single folder:
#install(FILES ${EXPORT_HEADER_LIST} DESTINATION include)
# this keep the basic path for each folders:
set(BASE "${PROJECT_SOURCE_DIR}/install")
foreach(ITEM ${EXPORT_HEADER_LIST})
get_filename_component(ITEM_PATH ${ITEM} PATH)
string(REPLACE ${BASE} "" ITEM_PATH ${ITEM_PATH})
install(FILES ${ITEM}
DESTINATION "include/${ITEM_PATH}"
COMPONENT Devel)
copy_file_with_reference(${MODULE_MAP_${LOCAL_MODULE_NAME}_FOLDER} ${III} ${MODULE_MAP_${LOCAL_MODULE_NAME}_INCLUDE_PUBLIC})
endforeach()
if(HAS_DATA_TO_BUILD)
set(TMP_LIST ${MODULE_MAP_${LOCAL_MODULE_NAME}_INCLUDE_LOCAL})
list(APPEND TMP_LIST ${MODULE_MAP_${LOCAL_MODULE_NAME}_INCLUDE_PUBLIC})
if(TMP_LIST)
target_include_directories(${LIBRARY_NAME222}_OBJ PUBLIC "${TMP_LIST}")
endif()
add_library(${LIBRARY_NAME222}_dynamic SHARED $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
add_library(${LIBRARY_NAME222}_static STATIC $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
if (LIST_PROJECT_DEPENDENCY)
foreach(III ${LIST_PROJECT_DEPENDENCY})
message(">>>>>>>> ${III}")
add_dependencies(${LIBRARY_NAME222}_dynamic "${III}_dynamic")
add_dependencies(${LIBRARY_NAME222}_static "${III}_static")
endforeach()
endif()
include(CMakePackageConfigHelpers)
#write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}ConfigVersion.cmake"
# VERSION ${LIBRARY_VERSION}
# COMPATIBILITY AnyNewerVersion
#)
#
#export(EXPORT ${LIBRARY_NAME222}Targets
# FILE "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Targets.cmake"
# NAMESPACE Upstream::
#)
##configure_file(cmake/${LIBRARY_NAME222}Config.cmake
## "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Config.cmake"
## COPYONLY
##)
set(CONFIG_PACKAGE_LOCATION cmake/${LIBRARY_NAME222})
install(EXPORT ${LIBRARY_NAME222}Targets
FILE
${LIBRARY_NAME222}Targets.cmake
NAMESPACE
${LIBRARY_NAME222}::
DESTINATION
${CONFIG_PACKAGE_LOCATION}
)
if ("${GLD_TARGET}" STREQUAL "Windows")
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
# static will keep the element static at the end (the windows architecture fore shared object need to have a static library to access to the DLL ==> create a conflict!!!
else()
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
set_target_properties(${LIBRARY_NAME222}_static PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
endif()
if (LIBRARY_VERSION)
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES VERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES SOVERSION ${LIBRARY_VERSION})
endif()
if (LIBRARY_DECRIPTION)
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES DESCRIPTION ${LIBRARY_DECRIPTION})
endif()
# install dynamic & static library
install(TARGETS ${LIBRARY_NAME222}_dynamic EXPORT ${LIBRARY_NAME222}Targets
RUNTIME DESTINATION ${MODULE_MAP_${LOCAL_MODULE_NAME}_LIB_PATH}
)
install(TARGETS ${LIBRARY_NAME222}_static
RUNTIME DESTINATION ${MODULE_MAP_${LOCAL_MODULE_NAME}_LIB_PATH})
#install(TARGETS ${LIBRARY_NAME222} EXPORT ${LIBRARY_NAME222}Targets
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# RUNTIME DESTINATION bin
# INCLUDES DESTINATION include
#)
# install exported headers
# this copy all the headers in a single folder:
#install(FILES ${EXPORT_HEADER_LIST} DESTINATION include)
# this keep the basic path for each folders:
set(BASE "${PROJECT_SOURCE_DIR}/install")
foreach(ITEM ${EXPORT_HEADER_LIST})
get_filename_component(ITEM_PATH ${ITEM} PATH)
string(REPLACE ${BASE} "" ITEM_PATH ${ITEM_PATH})
install(FILES ${ITEM}
DESTINATION "include/${ITEM_PATH}"
COMPONENT Devel)
endforeach()
include(CMakePackageConfigHelpers)
#write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}ConfigVersion.cmake"
# VERSION ${LIBRARY_VERSION}
# COMPATIBILITY AnyNewerVersion
#)
#
#export(EXPORT ${LIBRARY_NAME222}Targets
# FILE "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Targets.cmake"
# NAMESPACE Upstream::
#)
##configure_file(cmake/${LIBRARY_NAME222}Config.cmake
## "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Config.cmake"
## COPYONLY
##)
set(CONFIG_PACKAGE_LOCATION cmake/${LIBRARY_NAME222})
install(EXPORT ${LIBRARY_NAME222}Targets
FILE
${LIBRARY_NAME222}Targets.cmake
NAMESPACE
${LIBRARY_NAME222}::
DESTINATION
${CONFIG_PACKAGE_LOCATION}
)
endif()
#install(
# FILES
# cmake/${LIBRARY_NAME222}Config.cmake
@ -726,69 +609,6 @@ function(GLD_generate_cmake_wrapping LIST_OF_MODULE_AVAILLABLE)
endfunction()
##
## @brief List all folder in a specific inout folder.
## @param[out] VAR_OUT Result list of folders.
## @param[in] BASE_FOLDER Basic folder to parse.
##
function(sub_dir_list VAR_OUT BASE_FOLDER)
#message(" Search: ${BASE_FOLDER}" )
file(GLOB children "${BASE_FOLDER}/*")
#message(" ==>>> ${children}" )
set(dirlist "")
foreach(child ${children})
#message(" - ${child}" )
if(IS_DIRECTORY ${child})
#message(" ==> is directory" )
list(APPEND dirlist ${child})
endif()
endforeach()
set(${VAR_OUT} ${dirlist} PARENT_SCOPE)
endfunction()
##
## @brief Recursive search of a specific patter (stop whan find the pattern in a folder.
## (have a limit of parsing ==> optimise resarch in a worktree).
## @param[out] VAR_OUT List of all files that corespond of the reg-exp
## @param[in] BASE_FOLDER Basic folder to parse.
## @param[in] REG_EXP Regular expression to search the data.
## @param[in] LIMIT Lismit of folder to recursively parse.
##
function(find_all_files VAR_OUT BASE_FOLDER REG_EXP LIMIT)
if (${LIMIT} LESS_EQUAL 0)
set(${VAR_OUT} "" PARENT_SCOPE)
return()
endif()
MATH(EXPR LIMIT "${LIMIT}-1")
get_filename_component(BASE_FOLDER ${BASE_FOLDER} ABSOLUTE)
#message("KK Search in subDiratory: ${BASE_FOLDER}/${REG_EXP}" )
file(GLOB GLD_FILES "${BASE_FOLDER}/${REG_EXP}")
#message("Find file: '${GLD_FILES}'" )
if("${GLD_FILES}" STREQUAL "")
#message("Search in subDiratory: ${BASE_FOLDER}" )
# no element continue search...
set(SUBDIRS "")
sub_dir_list(SUBDIRS "${BASE_FOLDER}")
#message(" =!=> : ${SUBDIRS}" )
foreach(ELEM ${SUBDIRS})
get_filename_component(DIR_NAME_RELATIVE ${ELEM} NAME)
#message(" =!=> DIR_NAME_RELATIVE = ${DIR_NAME_RELATIVE}" )
if("${DIR_NAME_RELATIVE}" STREQUAL ".git" OR "${DIR_NAME_RELATIVE}" STREQUAL ".island" OR "${DIR_NAME_RELATIVE}" STREQUAL "archive" OR "${DIR_NAME_RELATIVE}" STREQUAL "out" OR "${DIR_NAME_RELATIVE}" STREQUAL "target")
continue()
endif()
if("${ELEM}" STREQUAL "${BASE_FOLDER}" OR "${ELEM}" STREQUAL "${BASE_FOLDER}/")
continue()
endif()
#message(" element: ${ELEM}" )
#message(" BASE_FOLDER: ${BASE_FOLDER}" )
find_all_files(OUT_SUB_LIST "${ELEM}" "${REG_EXP}" ${LIMIT})
list(APPEND GLD_FILES ${OUT_SUB_LIST})
endforeach()
endif()
set(${VAR_OUT} ${GLD_FILES} PARENT_SCOPE)
endfunction()
function(GLD_get_full_dependency_group VAR_OUT VAR_OPTIONAL_OUT MY_JSON_STRING ELEMENT_TO_CHECK TYPE_VARIABLE)
set(LIST_VALUE "")
@ -899,7 +719,7 @@ function(GLD_get_full_dependency VAR_OUT VAR_OPTIONAL_OUT MY_JSON_STRING)
list(APPEND LIST_VALUE ${VAR_OUT_TMP})
list(APPEND LIST_OPTIONAL_VALUE ${LIST_OPTIONAL_VALUE_TMP})
GLD_get_full_dependency_group(VAR_OUT_TMP LIST_OPTIONAL_VALUE_TMP MY_JSON_STRING "compilator" ${GLD_COMPILATOR})
GLD_get_full_dependency_group(VAR_OUT_TMP LIST_OPTIONAL_VALUE_TMP MY_JSON_STRING "compiler" ${GLD_COMPILER})
list(APPEND LIST_VALUE ${VAR_OUT_TMP})
list(APPEND LIST_OPTIONAL_VALUE ${LIST_OPTIONAL_VALUE_TMP})
@ -1069,7 +889,7 @@ endfunction()
function(GLD_load_all ROOT_FOLDER BASE_NAME COMMENT_ACTION)
message("Parse all files ${BASE_NAME}*.json: base: ${ROOT_FOLDER}")
#file(GLOB_RECURSE GLD_FILES "${ROOT_FOLDER}/GLD_*.json")
find_all_files(GLD_FILES "${ROOT_FOLDER}" "${BASE_NAME}*.json" 5)
find_all_files_exeption(GLD_FILES "${ROOT_FOLDER}" "${BASE_NAME}*.json" 5)
message("List of GLD files:")
foreach(III ${GLD_FILES})
GET_FILENAME_COMPONENT(FILENAME ${III} NAME_WE)

106
cmake/GLDJson.cmake Normal file
View File

@ -0,0 +1,106 @@
cmake_minimum_required(VERSION 3.20)
##
## @brief get the type of a variable
## @param[in] INPUT_JSON Json data.
## @param[in] VARIABLE Name of the variable.
## @param[out] OUT_VAR Retrun type of the node: NULL, NUMBER, STRING, BOOLEAN, ARRAY, OBJECT or NOTFOUND (if does not exist)
##
function(json_get_type OUT_VAR INPUT_JSON VARIABLE)
string(JSON VALUE ERROR_VARIABLE ${VARIABLE} TYPE ${INPUT_JSON} ${VARIABLE})
if (${VALUE} STREQUAL ${VARIABLE}-NOTFOUND)
set(${OUT_VAR} "NOTFOUND" PARENT_SCOPE)
else()
set(${OUT_VAR} "${VALUE}" PARENT_SCOPE)
endif()
endfunction()
function(json_size OUT_VAR INPUT_JSON VARIABLE)
string(JSON VALUE ERROR_VARIABLE ${VARIABLE} LENGTH ${INPUT_JSON} ${VARIABLE})
if (${VALUE} STREQUAL ${VARIABLE}-NOTFOUND)
set("${OUT_VAR}" 0 PARENT_SCOPE)
else ()
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endif()
endfunction()
function(json_get_data OUT_VAR INPUT_JSON VARIABLE)
string(JSON VALUE GET ${INPUT_JSON} ${VARIABLE})
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endfunction()
function(json_get_data_or_default OUT_VAR INPUT_JSON VARIABLE DEFAULT_VALUE)
json_get_type(TYPE ${INPUT_JSON} ${VARIABLE})
if (${TYPE} STREQUAL "NOTFOUND")
set("${OUT_VAR}" ${DEFAULT_VALUE} PARENT_SCOPE)
else()
string(JSON VALUE GET ${INPUT_JSON} ${VARIABLE})
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endif()
endfunction()
function(json_object_key OUT_VAR INPUT_JSON IDX)
string(JSON VALUE MEMBER ${INPUT_JSON} ${IDX})
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endfunction()
function(json_object_keys OUT_VAR MY_JSON_STRING VARIABLE)
json_size(SIZE ${MY_JSON_STRING} ${VARIABLE})
#message("target SIZE = ${SIZE}")
json_get_data(OBJECT_DATA ${MY_JSON_STRING} ${VARIABLE})
if (SIZE EQUAL 0)
return()
endif()
MATH(EXPR SIZE "${SIZE}-1")
set(OUT "")
foreach(IDX RANGE ${SIZE})
json_object_key(ELEMENT ${OBJECT_DATA} ${IDX})
#message(" - : ${ELEMENT}")
list(APPEND OUT ${ELEMENT})
endforeach()
set("${OUT_VAR}" ${OUT} PARENT_SCOPE)
endfunction()
function(json_object_values OUT_VAR INPUT_JSON VARIABLE KEYS)
string(JSON VALUE GET ${INPUT_JSON} ${VARIABLE} ${KEYS})
set("${OUT_VAR}" ${VALUE} PARENT_SCOPE)
endfunction()
function(json_get_list OUT_VAR INPUT_JSON VARIABLE)
string(JSON LIST_JSON_ELEMENTS ERROR_VARIABLE ${VARIABLE} GET ${INPUT_JSON} ${VARIABLE})
if (${LIST_JSON_ELEMENTS} STREQUAL ${VARIABLE}-NOTFOUND)
set("${OUT_VAR}" PARENT_SCOPE)
retrun()
endif()
#message("LIST_JSON_ELEMENTS : ${LIST_JSON_ELEMENTS}")
string(JSON LENGTH_VALUE LENGTH ${LIST_JSON_ELEMENTS})
#message("LENGTH_VALUE : ${LENGTH_VALUE}")
if (${LENGTH_VALUE} EQUAL 0)
set("${OUT_VAR}" PARENT_SCOPE)
retrun()
endif()
set(OUT_LIST)
MATH(EXPR LENGTH_VALUE "${LENGTH_VALUE}-1")
foreach(IDX RANGE ${LENGTH_VALUE})
string(JSON ELEM GET ${LIST_JSON_ELEMENTS} ${IDX})
#message(" - : ${ELEM}")
list(APPEND OUT_LIST ${ELEM})
endforeach()
#message("OUT_LIST : ${OUT_LIST}")
set("${OUT_VAR}" ${OUT_LIST} PARENT_SCOPE)
endfunction()
function(json_get_element OUT_VAR INPUT_JSON VARIABLE)
string(JSON ELEMENT ERROR_VARIABLE ${VARIABLE} GET ${INPUT_JSON} ${VARIABLE})
if ("${ELEMENT}" STREQUAL "${VARIABLE}-NOTFOUND")
set("${OUT_VAR}" "" PARENT_SCOPE)
elseif ("${ELEMENT}" STREQUAL "NOTFOUND")
set("${OUT_VAR}" "" PARENT_SCOPE)
else()
set("${OUT_VAR}" ${ELEMENT} PARENT_SCOPE)
endif()
endfunction()

113
cmake/GLDTargetConfig.cmake Normal file
View File

@ -0,0 +1,113 @@
cmake_minimum_required(VERSION 3.20)
if (WIN32)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
endif()
set(CPACK_VERBATIM_VARIABLES YES)
include(CPack)
## fist step is determining the target:
if (WIN32)
set(GLD_TARGET "Windows" CACHE INTERNAL "")
elseif(APPLE)
set(GLD_TARGET "MacOs" CACHE INTERNAL "")
elseif(LINUX)
set(GLD_TARGET "Linux" CACHE INTERNAL "")
elseif(UNIX AND NOT APPLE)
set(GLD_TARGET "Linux" CACHE INTERNAL "")
else()
message("GLD Can not determine the target !!!")
exit(-1)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(GLD_COMPILER "clang" CACHE INTERNAL "")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(GLD_COMPILER "gcc" CACHE INTERNAL "")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(GLD_COMPILER "intel" CACHE INTERNAL "")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(GLD_COMPILER "msvc" CACHE INTERNAL "")
else()
message("GLD Can not determine the compilator !!!")
exit(-1)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(GLD_MODE "debug" CACHE INTERNAL "")
elseif(CMAKE_BUILD_TYPE STREQUAL "debug")
set(GLD_MODE "debug" CACHE INTERNAL "")
else()
set(GLD_MODE "release" CACHE INTERNAL "")
endif()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
set(GLD_ARCH "x86" CACHE INTERNAL "")
set(GLD_BUS_SIZE "64" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
set(GLD_ARCH "x86" CACHE INTERNAL "")
set(GLD_BUS_SIZE "32" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64")
set(GLD_ARCH "ppc" CACHE INTERNAL "")
set(GLD_BUS_SIZE "64" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc")
set(GLD_ARCH "ppc" CACHE INTERNAL "")
set(GLD_BUS_SIZE "32" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(GLD_ARCH "arm" CACHE INTERNAL "")
set(GLD_BUS_SIZE "64" CACHE INTERNAL "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l"
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "armv9")
set(GLD_ARCH "arm" CACHE INTERNAL "")
set(GLD_BUS_SIZE "32" CACHE INTERNAL "")
else()
message("GLD Can not determine the architecture and bus-size !!!")
exit(-1)
endif()
# cmake does not support other mode than "intricate" the "isolate" mode is too much complicated to do.
set(GLD_SANITY_MODE "intricate" CACHE INTERNAL "")
# list of current supported language:
# - 'c': C language
# - 'c++': C++ language
# - 'asm': asembler language
# - 'm': Objective-C language
# - 'mm': Objective-C++ language
# - 'java': Java language
# - 'javah': generated c header with Java description (for JNI)
# TODO: maybe permit user to add some other... like "in", "masm", or other pre-step generation code???
set(GLD_SUPPORT_LANGUAGE "c;asm;c++;m;mm;java;javah" CACHE INTERNAL "")
set(GLD_SUPPORT_LANGUAGE_VARIABLE "C;ASM;CXX;M;MM;JAVA;JAVAH" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_C "c;C" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_CXX "cpp;CPP;cxx;CXX" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_ASM "s;S" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_M "m;M" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_MM "mm;MM" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_JAVA "java" CACHE INTERNAL "")
set(GLD_LANGUAGE_EXTENTION_JAVAH "javah" CACHE INTERNAL "")
# where is build the module
set(GLD_GLOBAL_BUILD_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${GLD_TARGET}_${GLD_ARCH}_${GLD_BUS_SIZE}/${GLD_MODE}/build/${GLD_COMPILER}/" CACHE INTERNAL "")
# where the package is prepared
set(GLD_GLOBAL_STAGING_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${GLD_TARGET}_${GLD_ARCH}_${GLD_BUS_SIZE}/${GLD_MODE}/staging/${GLD_COMPILER}/" CACHE INTERNAL "")
# whe the bundle (tar, jar ...) is set
set(GLD_GLOBAL_FINAL_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/${GLD_TARGET}_${GLD_ARCH}_${GLD_BUS_SIZE}/${GLD_MODE}/final/${GLD_COMPILER}/" CACHE INTERNAL "")
message("Global GLD properties:")
message(" GLD_MODE : ${GLD_MODE}")
message(" GLD_COMPILER : ${GLD_COMPILER}")
message(" GLD_TARGET : ${GLD_TARGET}")
message(" GLD_ARCH : ${GLD_ARCH}")
message(" GLD_BUS_SIZE : ${GLD_BUS_SIZE}")
message(" GLD_SANITY_MODE : ${GLD_SANITY_MODE}")
message(" GLD_GLOBAL_BUILD_FOLDER : ${GLD_GLOBAL_BUILD_FOLDER}")
message(" GLD_GLOBAL_STAGING_FOLDER : ${GLD_GLOBAL_STAGING_FOLDER}")
message(" GLD_GLOBAL_FINAL_FOLDER : ${GLD_GLOBAL_FINAL_FOLDER}")

131
cmake/GLDTools.cmake Normal file
View File

@ -0,0 +1,131 @@
cmake_minimum_required(VERSION 3.20)
##
## @brief List all folder in a specific inout folder.
## @param[out] VAR_OUT Result list of folders.
## @param[in] BASE_FOLDER Basic folder to parse.
##
function(sub_dir_list VAR_OUT BASE_FOLDER)
#message(" Search: ${BASE_FOLDER}" )
file(GLOB CHILDREN "${BASE_FOLDER}/*")
#message(" ==>>> ${children}" )
set(OUT_DATA "")
foreach(CHILD ${CHILDREN})
#message(" - ${child}" )
if(IS_DIRECTORY ${CHILD})
#message(" ==> is directory" )
list(APPEND OUT_DATA ${CHILD})
endif()
endforeach()
set(${VAR_OUT} ${OUT_DATA} PARENT_SCOPE)
endfunction()
function(replace_base_path VAR_OUT BASE LIST_ELEMENT)
set(OUT_DATA "")
foreach(ELEM ${LIST_ELEMENT})
string(REPLACE "${BASE}" "" TMP_VARIABLE ${ELEM})
list(APPEND OUT_DATA ${TMP_VARIABLE})
endforeach()
set(${VAR_OUT} ${OUT_DATA} PARENT_SCOPE)
endfunction()
function(copy_file_with_reference BASE_PATH SRC DST)
#check if input function if compatible with changing folder model...
string(FIND "${SRC}" "!" POSITION_IN_FILE REVERSE)
#message("POSITION_IN_FILE=${POSITION_IN_FILE}")
if(${POSITION_IN_FILE} GREATER 0)
string(SUBSTRING "${SRC}" 0 ${POSITION_IN_FILE} FILE_NAME)
MATH(EXPR POSITION_IN_FILE "${POSITION_IN_FILE}+1")
string(SUBSTRING "${SRC}" ${POSITION_IN_FILE} -1 PART_2)
string(FIND "${PART_2}" ":" POSITION_IN_FILE REVERSE)
string(SUBSTRING "${PART_2}" 0 ${POSITION_IN_FILE} FOLDER_SRC)
MATH(EXPR POSITION_IN_FILE "${POSITION_IN_FILE}+1")
string(SUBSTRING "${PART_2}" ${POSITION_IN_FILE} -1 FOLDER_DST)
#message("***********************************************************************")
#message("FILE_NAME=${FILE_NAME}")
#message("FOLDER_SRC=${FOLDER_SRC}")
#message("FOLDER_DST=${FOLDER_DST}")
configure_file(${BASE_PATH}/${FOLDER_SRC}/${FILE_NAME} ${DST}/${FOLDER_DST}/${FILE_NAME} COPYONLY)
else()
configure_file(${BASE_PATH}/${SRC} ${DST}/${SRC} COPYONLY)
endif()
endfunction()
##
## @brief Recursive search of a specific patter (stop whan find the pattern in a folder.
## (have a limit of parsing ==> optimise resarch in a worktree).
## @param[out] VAR_OUT List of all files that corespond of the reg-exp
## @param[in] BASE_FOLDER Basic folder to parse.
## @param[in] REG_EXP Regular expression to search the data.
## @param[in] LIMIT Lismit of folder to recursively parse.
##
function(find_all_files VAR_OUT BASE_FOLDER REG_EXP LIMIT)
if (${LIMIT} LESS_EQUAL 0)
set(${VAR_OUT} "" PARENT_SCOPE)
return()
endif()
MATH(EXPR LIMIT "${LIMIT}-1")
get_filename_component(BASE_FOLDER ${BASE_FOLDER} ABSOLUTE)
#message("KK Search in subDiratory: ${BASE_FOLDER}/${REG_EXP}" )
file(GLOB TMP_FILES "${BASE_FOLDER}/${REG_EXP}")
#message("-end-" )
set(GLD_FILES "")
#message("Find file: '${GLD_FILES}'" )
foreach(ELEM ${TMP_FILES})
if(IS_DIRECTORY "${ELEM}")
get_filename_component(DIR_NAME_RELATIVE ${ELEM} NAME)
#message(" =!=> DIR_NAME_RELATIVE = ${DIR_NAME_RELATIVE}" )
if("${ELEM}" STREQUAL "${BASE_FOLDER}" OR "${ELEM}" STREQUAL "${BASE_FOLDER}/" OR "${ELEM}" STREQUAL ".")
continue()
endif()
#message(" element: ${ELEM}" )
#message(" BASE_FOLDER: ${BASE_FOLDER}" )
find_all_files(OUT_SUB_LIST "${ELEM}" "${REG_EXP}" ${LIMIT})
#message(" start Add 1" )
list(APPEND GLD_FILES ${OUT_SUB_LIST})
#message(" -end-" )
else()
#message(" start Add 2" )
list(APPEND GLD_FILES ${ELEM})
#message(" -end-" )
endif()
endforeach()
set(${VAR_OUT} ${GLD_FILES} PARENT_SCOPE)
endfunction()
function(find_all_files_exeption VAR_OUT BASE_FOLDER REG_EXP LIMIT)
if (${LIMIT} LESS_EQUAL 0)
set(${VAR_OUT} "" PARENT_SCOPE)
return()
endif()
MATH(EXPR LIMIT "${LIMIT}-1")
get_filename_component(BASE_FOLDER ${BASE_FOLDER} ABSOLUTE)
#message("KK Search in subDiratory: ${BASE_FOLDER}/${REG_EXP}" )
file(GLOB GLD_FILES "${BASE_FOLDER}/${REG_EXP}")
#message("Find file: '${GLD_FILES}'" )
if("${GLD_FILES}" STREQUAL "")
#message("Search in subDiratory: ${BASE_FOLDER}" )
# no element continue search...
set(SUBDIRS "")
sub_dir_list(SUBDIRS "${BASE_FOLDER}")
#message(" =!=> : ${SUBDIRS}" )
foreach(ELEM ${SUBDIRS})
get_filename_component(DIR_NAME_RELATIVE ${ELEM} NAME)
#message(" =!=> DIR_NAME_RELATIVE = ${DIR_NAME_RELATIVE}" )
if("${DIR_NAME_RELATIVE}" STREQUAL ".git" OR "${DIR_NAME_RELATIVE}" STREQUAL ".island" OR "${DIR_NAME_RELATIVE}" STREQUAL "archive" OR "${DIR_NAME_RELATIVE}" STREQUAL "out" OR "${DIR_NAME_RELATIVE}" STREQUAL "target" OR "${DIR_NAME_RELATIVE}" STREQUAL "lutin")
continue()
endif()
if("${ELEM}" STREQUAL "${BASE_FOLDER}" OR "${ELEM}" STREQUAL "${BASE_FOLDER}/")
continue()
endif()
#message(" element: ${ELEM}" )
#message(" BASE_FOLDER: ${BASE_FOLDER}" )
find_all_files_exeption(OUT_SUB_LIST "${ELEM}" "${REG_EXP}" ${LIMIT})
list(APPEND GLD_FILES ${OUT_SUB_LIST})
endforeach()
endif()
set(${VAR_OUT} ${GLD_FILES} PARENT_SCOPE)
endfunction()

351
cmake/old.cmake Normal file
View File

@ -0,0 +1,351 @@
function(GLD_import_old FOLDER LIBRARY_NAME)
# add the executable
# add_executable(Tutorial tutorial.cxx)
set(LIBRARY_NAME "etk-core")
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GLD_${LIBRARY_NAME}.json
)
# Read the JSON file.
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/GLD_${LIBRARY_NAME}.json MY_JSON_STRING)
# Loop through each element of the JSON array (indices 0 though 1).
json_get_element(LIBRARY_TYPE ${MY_JSON_STRING} "type")
json_get_element(LIBRARY_GROUP_ID ${MY_JSON_STRING} "group-id")
json_get_element(LIBRARY_DECRIPTION ${MY_JSON_STRING} "description")
json_get_element(LIBRARY_LICENCE ${MY_JSON_STRING} "licence")
json_get_element(LIBRARY_LICENCE_FILE ${MY_JSON_STRING} "licence-file")
json_get_element(LIBRARY_MAINTAINER ${MY_JSON_STRING} "maintainer")
json_get_element(LIBRARY_AUTHORS ${MY_JSON_STRING} "authors")
json_get_element(LIBRARY_VERSION ${MY_JSON_STRING} "version")
json_get_element(LIBRARY_SOURCES ${MY_JSON_STRING} "sources")
json_get_element(LIBRARY_HEADERS ${MY_JSON_STRING} "headers")
json_get_list(LIBRARY_PATH ${MY_JSON_STRING} "path")
json_get_element(LIBRARY_COMPILATION_VERSION ${MY_JSON_STRING} "compilation-version")
json_get_list(LIBRARY_DEPENDENCY ${MY_JSON_STRING} "dependency")
json_get_element(LIBRARY_TARGET ${MY_JSON_STRING} "target")
json_get_element(LIBRARY_COMPILATION_VERSION_LANGUAGE ${MY_JSON_STRING} "language")
json_get_element(LIBRARY_COMPILATION_VERSION_VALUE ${MY_JSON_STRING} "version")
message("LIBRARY_NAME : ${LIBRARY_NAME}")
message("LIBRARY_TYPE : ${LIBRARY_TYPE}")
message("LIBRARY_GROUP_ID : ${LIBRARY_GROUP_ID}")
message("LIBRARY_DECRIPTION : ${LIBRARY_DECRIPTION}")
message("LIBRARY_LICENCE : ${LIBRARY_LICENCE}")
message("LIBRARY_LICENCE_FILE : ${LIBRARY_LICENCE_FILE}")
message("LIBRARY_MAINTAINER : ${LIBRARY_MAINTAINER}")
message("LIBRARY_AUTHORS : ${LIBRARY_AUTHORS}")
message("LIBRARY_VERSION : ${LIBRARY_VERSION}")
message("LIBRARY_COMPILATION_VERSION : ${LIBRARY_COMPILATION_VERSION_LANGUAGE} : ${LIBRARY_COMPILATION_VERSION_VALUE}")
#message("LIBRARY_SOURCES: ${LIBRARY_SOURCES}")
#message("LIBRARY_HEADERS: ${LIBRARY_HEADERS}")
message("LIBRARY_PATH: ${LIBRARY_PATH}")
#message("LIBRARY_COMPILATION_VERSION: ${LIBRARY_COMPILATION_VERSION}")
message("LIBRARY_DEPENDENCY: ${LIBRARY_DEPENDENCY}")
#message("LIBRARY_TARGET: ${LIBRARY_TARGET}")
json_get_list(SOURCES_LIST ${LIBRARY_SOURCES} "list")
message("SOURCES_LIST: ${SOURCES_LIST}")
json_get_list(EXPORT_HEADER_LIST ${LIBRARY_HEADERS} "list")
json_get_element(EXPORT_HEADER_LIST_PATH ${LIBRARY_HEADERS} "destination-path")
message("EXPORT_HEADER_LIST: ${EXPORT_HEADER_LIST}")
message("EXPORT_HEADER_LIST_PATH: ${EXPORT_HEADER_LIST_PATH}")
string(JSON LIBRARY_PLOP ERROR_VARIABLE "qsdfqsdfqsdf" GET ${MY_JSON_STRING} "qsdfqsdfqsdf")
#string(JSON LIBRARY_MEMBERS MEMBER ${MY_JSON_STRING} )
#message("LIBRARY_MEMBERS : ${LIBRARY_MEMBERS}")
message("LIBRARY_PLOP : ${LIBRARY_PLOP}")
string(REPLACE "-" "_" LIBRARY_NAME222 ${LIBRARY_NAME})
set(LIBRARY_NAME222 ${LIBRARY_NAME})
project(${LIBRARY_NAME222} VERSION ${LIBRARY_VERSION})
set(${LIBRARY_NAME222} PROPERTIES CPACK_PACKAGE_VERSION ${LIBRARY_VERSION})
add_library(${LIBRARY_NAME222}_OBJ OBJECT ${SOURCES_LIST})
# shared libraries need PIC
set_property(TARGET ${LIBRARY_NAME222}_OBJ PROPERTY POSITION_INDEPENDENT_CODE 1)
#set_target_properties(${LIBRARY_NAME222} PROPERTIES PUBLIC_HEADER ${EXPORT_HEADER_LIST})
target_include_directories(${LIBRARY_NAME222}_OBJ PUBLIC
${LIBRARY_PATH}
)
add_library(${LIBRARY_NAME222}_dynamic SHARED $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
add_library(${LIBRARY_NAME222}_static STATIC $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
if (NOT WIN32)
set_target_properties(${LIBRARY_NAME222}_static PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
endif()
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES VERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES SOVERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES DESCRIPTION ${LIBRARY_DECRIPTION})
# install dynamic & static library
install(TARGETS ${LIBRARY_NAME222}_dynamic EXPORT ${LIBRARY_NAME222}Targets
RUNTIME DESTINATION lib
)
install(TARGETS ${LIBRARY_NAME222}_static
RUNTIME DESTINATION lib)
#install(TARGETS ${LIBRARY_NAME222} EXPORT ${LIBRARY_NAME222}Targets
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# RUNTIME DESTINATION bin
# INCLUDES DESTINATION include
#)
# install exported headers
# this copy all the headers in a single folder:
#install(FILES ${EXPORT_HEADER_LIST} DESTINATION include)
# this keep the basic path for each folders:
set(BASE "${PROJECT_SOURCE_DIR}/install")
foreach(ITEM ${EXPORT_HEADER_LIST})
get_filename_component(ITEM_PATH ${ITEM} PATH)
string(REPLACE ${BASE} "" ITEM_PATH ${ITEM_PATH})
install(FILES ${ITEM}
DESTINATION "include/${ITEM_PATH}"
COMPONENT Devel)
endforeach()
include(CMakePackageConfigHelpers)
#write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}ConfigVersion.cmake"
# VERSION ${LIBRARY_VERSION}
# COMPATIBILITY AnyNewerVersion
#)
#
#export(EXPORT ${LIBRARY_NAME222}Targets
# FILE "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Targets.cmake"
# NAMESPACE Upstream::
#)
##configure_file(cmake/${LIBRARY_NAME222}Config.cmake
## "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Config.cmake"
## COPYONLY
##)
set(CONFIG_PACKAGE_LOCATION cmake/${LIBRARY_NAME222})
install(EXPORT ${LIBRARY_NAME222}Targets
FILE
${LIBRARY_NAME222}Targets.cmake
NAMESPACE
${LIBRARY_NAME222}::
DESTINATION
${CONFIG_PACKAGE_LOCATION}
)
#install(
# FILES
# cmake/${LIBRARY_NAME222}Config.cmake
# "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}ConfigVersion.cmake"
# DESTINATION
# ${CONFIG_PACKAGE_LOCATION}
# COMPONENT
# Devel
#)
message("CMAKE_INSTALL_LIBDIR===${CMAKE_INSTALL_LIBDIR}")
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/${LIBRARY_NAME222}Config.cmake.in
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}Config.cmake"
INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}ConfigVersion.cmake"
VERSION ${LIBRARY_VERSION}
COMPATIBILITY SameMajorVersion)
install(
FILES
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}Config.cmake"
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}ConfigVersion.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION}
COMPONENT Devel)
endfunction()
function(kjhghkjgkhjgkjhgkjhgkj LIBRARY_NAME)
json_get_element(LIBRARY_SOURCES ${MY_JSON_STRING} "source")
json_get_element(LIBRARY_HEADERS ${MY_JSON_STRING} "header")
json_get_list(LIBRARY_PATH ${MY_JSON_STRING} "path")
json_get_element(LIBRARY_COMPILATION_VERSION ${MY_JSON_STRING} "compilation-version")
json_get_list(LIBRARY_DEPENDENCY ${MY_JSON_STRING} "dependency")
json_get_element(LIBRARY_TARGET ${MY_JSON_STRING} "target")
json_get_element(LIBRARY_COMPILATION_VERSION_LANGUAGE ${MY_JSON_STRING} "language")
json_get_element(LIBRARY_COMPILATION_VERSION_VALUE ${MY_JSON_STRING} "version")
message("LIBRARY_COMPILATION_VERSION : ${LIBRARY_COMPILATION_VERSION_LANGUAGE} : ${LIBRARY_COMPILATION_VERSION_VALUE}")
#message("LIBRARY_SOURCES: ${LIBRARY_SOURCES}")
#message("LIBRARY_HEADERS: ${LIBRARY_HEADERS}")
message("LIBRARY_PATH: ${LIBRARY_PATH}")
#message("LIBRARY_COMPILATION_VERSION: ${LIBRARY_COMPILATION_VERSION}")
message("LIBRARY_DEPENDENCY: ${LIBRARY_DEPENDENCY}")
#message("LIBRARY_TARGET: ${LIBRARY_TARGET}")
json_get_list(SOURCES_LIST ${LIBRARY_SOURCES} "list")
message("SOURCES_LIST: ${SOURCES_LIST}")
json_get_list(EXPORT_HEADER_LIST ${LIBRARY_HEADERS} "list")
json_get_element(EXPORT_HEADER_LIST_PATH ${LIBRARY_HEADERS} "destination-path")
message("EXPORT_HEADER_LIST: ${EXPORT_HEADER_LIST}")
message("EXPORT_HEADER_LIST_PATH: ${EXPORT_HEADER_LIST_PATH}")
string(JSON LIBRARY_PLOP ERROR_VARIABLE "qsdfqsdfqsdf" GET ${MY_JSON_STRING} "qsdfqsdfqsdf")
#string(JSON LIBRARY_MEMBERS MEMBER ${MY_JSON_STRING} )
#message("LIBRARY_MEMBERS : ${LIBRARY_MEMBERS}")
message("LIBRARY_PLOP : ${LIBRARY_PLOP}")
string(REPLACE "-" "_" LIBRARY_NAME222 ${LIBRARY_NAME})
set(LIBRARY_NAME222 ${LIBRARY_NAME})
project(${LIBRARY_NAME222} VERSION ${LIBRARY_VERSION})
set(${LIBRARY_NAME222} PROPERTIES CPACK_PACKAGE_VERSION ${LIBRARY_VERSION})
add_library(${LIBRARY_NAME222}_OBJ OBJECT ${SOURCES_LIST})
# shared libraries need PIC
set_property(TARGET ${LIBRARY_NAME222}_OBJ PROPERTY POSITION_INDEPENDENT_CODE 1)
#set_target_properties(${LIBRARY_NAME222} PROPERTIES PUBLIC_HEADER ${EXPORT_HEADER_LIST})
target_include_directories(${LIBRARY_NAME222}_OBJ PUBLIC
${LIBRARY_PATH}
)
add_library(${LIBRARY_NAME222}_dynamic SHARED $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
add_library(${LIBRARY_NAME222}_static STATIC $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
if (NOT WIN32)
set_target_properties(${LIBRARY_NAME222}_static PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
endif()
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES VERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES SOVERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES DESCRIPTION ${LIBRARY_DECRIPTION})
# install dynamic & static library
install(TARGETS ${LIBRARY_NAME222}_dynamic EXPORT ${LIBRARY_NAME222}Targets
RUNTIME DESTINATION lib
)
install(TARGETS ${LIBRARY_NAME222}_static
RUNTIME DESTINATION lib)
#install(TARGETS ${LIBRARY_NAME222} EXPORT ${LIBRARY_NAME222}Targets
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# RUNTIME DESTINATION bin
# INCLUDES DESTINATION include
#)
# install exported headers
# this copy all the headers in a single folder:
#install(FILES ${EXPORT_HEADER_LIST} DESTINATION include)
# this keep the basic path for each folders:
set(BASE "${PROJECT_SOURCE_DIR}/install")
foreach(ITEM ${EXPORT_HEADER_LIST})
get_filename_component(ITEM_PATH ${ITEM} PATH)
string(REPLACE ${BASE} "" ITEM_PATH ${ITEM_PATH})
install(FILES ${ITEM}
DESTINATION "include/${ITEM_PATH}"
COMPONENT Devel)
endforeach()
include(CMakePackageConfigHelpers)
#write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}ConfigVersion.cmake"
# VERSION ${LIBRARY_VERSION}
# COMPATIBILITY AnyNewerVersion
#)
#
#export(EXPORT ${LIBRARY_NAME222}Targets
# FILE "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Targets.cmake"
# NAMESPACE Upstream::
#)
##configure_file(cmake/${LIBRARY_NAME222}Config.cmake
## "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}Config.cmake"
## COPYONLY
##)
set(CONFIG_PACKAGE_LOCATION cmake/${LIBRARY_NAME222})
install(EXPORT ${LIBRARY_NAME222}Targets
FILE
${LIBRARY_NAME222}Targets.cmake
NAMESPACE
${LIBRARY_NAME222}::
DESTINATION
${CONFIG_PACKAGE_LOCATION}
)
#install(
# FILES
# cmake/${LIBRARY_NAME222}Config.cmake
# "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME222}/${LIBRARY_NAME222}ConfigVersion.cmake"
# DESTINATION
# ${CONFIG_PACKAGE_LOCATION}
# COMPONENT
# Devel
#)
message("CMAKE_INSTALL_LIBDIR===${CMAKE_INSTALL_LIBDIR}")
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/${LIBRARY_NAME222}Config.cmake.in
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}Config.cmake"
INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}ConfigVersion.cmake"
VERSION ${LIBRARY_VERSION}
COMPATIBILITY SameMajorVersion)
install(
FILES
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}Config.cmake"
"${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}ConfigVersion.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION}
COMPONENT Devel)
endfunction()

View File

@ -69,7 +69,7 @@ list_of_element_availlable=[
"dependency",
"copy",
"flag",
"compilator", # todo
"compiler",
"mode",
"target",
"arch",
@ -440,13 +440,10 @@ def parse_node_generic(target, path, json_path, my_module, data, first = False )
debug.error("Wrong type for node 'dependency' []");
if "compilation-version" in data.keys():
if type(data["compilation-version"]) == list:
for elem in data["compilation-version"]:
GLD_compile_version(my_module, elem);
elif type(data["compilation-version"]) == dict:
if type(data["compilation-version"]) == dict:
GLD_compile_version(my_module, data["compilation-version"]);
else:
debug.error("Wrong type for node 'compilation-version' [] or {}");
debug.error("Wrong type for node 'compilation-version' {'??lang??':1234}");
if "copy" in data.keys():
if type(data["copy"]) == list:
@ -546,6 +543,12 @@ def GLD_add_depend(my_module, data):
header_file = [ data["header"] ];
else:
debug.error("Can not have dependency 'header' in an other type than [] or string: '" + str(data["header"]) + "'");
compiler={}
if "compiler" in data.keys():
if type(data["compiler"]) == dict:
compiler = data["compiler"];
else:
debug.error("Can not have dependency 'compiler' in an other type than {}: '" + str(data["compiler"]) + "'");
if optional == False:
@ -559,11 +562,9 @@ def GLD_add_depend(my_module, data):
debug.error("dependency only support [ {} or string ]");
def GLD_compile_version(my_module, data):
if "language" in data.keys() and "version" in data.keys():
my_module.compile_version(data["language"], data["version"])
else:
debug.error("missing 'language' and/or 'version' in node 'compilation-version:{}'");
for elem in data.keys():
my_module.compile_version(elem, data[elem])
def GLD_copy(my_module, data):
path_src = None;
file_src = None;