diff --git a/cmake/cmaize/package_managers/cmake/cmake_package_manager.cmake b/cmake/cmaize/package_managers/cmake/cmake_package_manager.cmake index f24b2cb0..99adb124 100644 --- a/cmake/cmaize/package_managers/cmake/cmake_package_manager.cmake +++ b/cmake/cmaize/package_managers/cmake/cmake_package_manager.cmake @@ -132,21 +132,20 @@ cpp_class(CMakePackageManager PackageManager) cpp_map(GET "${_rd_dependencies}" _rd_temp "${_rd_key}") endforeach() + message(VERBOSE "Registering dependency to package manager: ${_rd_pkg_name}") if("${_rd_depend}" STREQUAL "") - message(DEBUG "Registering dependency to package manager: ${_rd_pkg_name}") - set(_rd_depend "") if("${ARGN}" MATCHES "github") - message("Creating a GitHub dependency") GitHubDependency(CTOR _rd_depend) else() - message("Creating a Git dependency") GitDependency(CTOR _rd_depend) endif() Dependency(init "${_rd_depend}" NAME "${_rd_pkg_name}" ${ARGN}) cpp_map(SET "${_rd_dependencies}" "${_rd_pkg_name}" "${_rd_depend}") + else() + message(VERBOSE "Dependency already registered to package manager: ${_rd_pkg_name}") endif() set("${_rd_result}" "${_rd_depend}") @@ -189,8 +188,6 @@ cpp_class(CMakePackageManager PackageManager) PackageSpecification(GET "${_fi_package_specs}" _fi_pkg_name name) - message(STATUS "Looking for ${_fi_pkg_name}") - CMakePackageManager(register_dependency "${self}" _fi_depend @@ -261,9 +258,13 @@ cpp_class(CMakePackageManager PackageManager) # Alias the build target as the find_target to unify the API if(NOT TARGET "${_gp_find_target}") + message(DEBUG "Find target does not exist: ${_gp_find_target}") if(NOT "${_gp_find_target}" STREQUAL "${_gp_build_target}") + message(DEBUG "Aliasing build target \"${_gp_build_target}\" as find target \"${_gp_find_target}\"") add_library("${_gp_find_target}" ALIAS "${_gp_build_target}") endif() + else() + message(DEBUG "Find target exists: ${_gp_find_target}") endif() cpp_return("${_gp_result}") diff --git a/cmake/cmaize/package_managers/cmake/dependency/dependency_class.cmake b/cmake/cmaize/package_managers/cmake/dependency/dependency_class.cmake index c39dd40f..51e1373d 100644 --- a/cmake/cmaize/package_managers/cmake/dependency/dependency_class.cmake +++ b/cmake/cmaize/package_managers/cmake/dependency/dependency_class.cmake @@ -102,8 +102,8 @@ cpp_class(Dependency) # Check if it was already found? If so short-circuit and return TRUE Dependency(GET "${self}" "${_fd_found}" found) - message("Was already found? ${${_fd_found}}") if("${${_fd_found}}") + message(STATUS "Dependency already found") cpp_return("${_fd_found}") endif() @@ -111,6 +111,7 @@ cpp_class(Dependency) Dependency(_SEARCH_PATHS "${self}" _fd_paths) Dependency(GET "${self}" _fd_name name) Dependency(GET "${self}" _fd_version version) + message(VERBOSE "Searching via find_package...") find_package( "${_fd_name}" CONFIG @@ -169,6 +170,15 @@ cpp_class(Dependency) Dependency(SET "${self}" build_target "${_i_BUILD_TARGET}") Dependency(SET "${self}" find_target "${_i_FIND_TARGET}") + message(VERBOSE "Created Dependency") + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(VERBOSE "Name: ${_i_NAME}") + message(VERBOSE "URL: ${_i_URL}") + message(VERBOSE "Version: ${_i_VERSION}") + message(VERBOSE "Build Target: ${_i_BUILD_TARGET}") + message(VERBOSE "Find Target: ${_i_FIND_TARGET}") + list(POP_BACK CMAKE_MESSAGE_INDENT) + endfunction() #[[[ Computes a list of path prefixes which should be used when searching. diff --git a/cmake/cmaize/package_managers/cmake/dependency/git.cmake b/cmake/cmaize/package_managers/cmake/dependency/git.cmake index 5ca97509..8eb74365 100644 --- a/cmake/cmaize/package_managers/cmake/dependency/git.cmake +++ b/cmake/cmaize/package_managers/cmake/dependency/git.cmake @@ -59,6 +59,8 @@ cpp_class(GitDependency Dependency) set("${_bd_var}" "${_bd_val}" CACHE BOOL "" FORCE) endforeach() + message(VERBOSE "Adding \"${_bd_name}\" to build system") + cmaize_fetch_and_available( "${_bd_name}" GIT_REPOSITORY "${_bd_url}.git" @@ -118,6 +120,16 @@ cpp_class(GitDependency Dependency) GitDependency(SET "${self}" find_target "${_i_FIND_TARGET}") GitDependency(SET "${self}" cmake_args "${_i_CMAKE_ARGS}") + message(VERBOSE "Created Git Dependency") + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(VERBOSE "Name: ${_i_NAME}") + message(VERBOSE "URL: ${_i_URL}") + message(VERBOSE "Version: ${_i_VERSION}") + message(VERBOSE "Build Target: ${_i_BUILD_TARGET}") + message(VERBOSE "Find Target: ${_i_FIND_TARGET}") + message(VERBOSE "CMake Args: ${_i_CMAKE_ARGS}") + list(POP_BACK CMAKE_MESSAGE_INDENT) + endfunction() cpp_end_class() diff --git a/cmake/cmaize/package_managers/cmake/dependency/github.cmake b/cmake/cmaize/package_managers/cmake/dependency/github.cmake index 73e40569..465d4528 100644 --- a/cmake/cmaize/package_managers/cmake/dependency/github.cmake +++ b/cmake/cmaize/package_managers/cmake/dependency/github.cmake @@ -166,6 +166,17 @@ cpp_class(GitHubDependency GitDependency) Dependency(SET "${self}" cmake_args "${_i_CMAKE_ARGS}") + message(VERBOSE "Created Git Dependency") + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(VERBOSE "Name: ${_i_NAME}") + message(VERBOSE "URL: ${_i_URL}") + message(VERBOSE "Version: ${_i_VERSION}") + message(VERBOSE "Private: ${_i_PRIVATE}") + message(VERBOSE "Build Target: ${_i_BUILD_TARGET}") + message(VERBOSE "Find Target: ${_i_FIND_TARGET}") + message(VERBOSE "CMake Args: ${_i_CMAKE_ARGS}") + list(POP_BACK CMAKE_MESSAGE_INDENT) + endfunction() cpp_end_class() diff --git a/cmake/cmaize/package_managers/cmake/impl_/generate_package_config.cmake b/cmake/cmaize/package_managers/cmake/impl_/generate_package_config.cmake index 024aa872..5558c2b2 100644 --- a/cmake/cmaize/package_managers/cmake/impl_/generate_package_config.cmake +++ b/cmake/cmaize/package_managers/cmake/impl_/generate_package_config.cmake @@ -123,19 +123,22 @@ macro( Dependency(GET "${__gpc_dep_obj}" __gpc_dep_build_tgt_name build_target ) + Dependency(GET + "${__gpc_dep_obj}" __gpc_tgt_dep_name name + ) # This determines how the find_dependency call in the config # file should be formatted, based on whether the dependency is # a component of a package or not - if("${__gpc_tgt_deps_i}" STREQUAL "${__gpc_dep_build_tgt_name}") + if("${__gpc_tgt_dep_name}" STREQUAL "${__gpc_dep_build_tgt_name}") string(APPEND __gpc_file_contents - "find_dependency(${__gpc_tgt_deps_i})\n" + "find_dependency(${__gpc_tgt_dep_name})\n" ) else() string(APPEND __gpc_file_contents - "find_dependency(${__gpc_tgt_deps_i} COMPONENTS ${__gpc_dep_build_tgt_name})\n" + "find_dependency(${__gpc_tgt_dep_name} COMPONENTS ${__gpc_dep_build_tgt_name})\n" ) endif() diff --git a/cmake/cmaize/package_managers/cmake/impl_/generate_target_config.cmake b/cmake/cmaize/package_managers/cmake/impl_/generate_target_config.cmake index 582a45b4..332f278b 100644 --- a/cmake/cmaize/package_managers/cmake/impl_/generate_target_config.cmake +++ b/cmake/cmaize/package_managers/cmake/impl_/generate_target_config.cmake @@ -30,8 +30,9 @@ macro(_cpm_generate_target_config_impl __gtc_file_contents " if(TARGET ${__gtc_namespace}${__gtc_target_name}) -return() -endif()") + return() +endif()" + ) string(APPEND __gtc_file_contents "\n\n") string(APPEND @@ -40,28 +41,89 @@ endif()") "\"\${CMAKE_CURRENT_LIST_DIR}/../../..\" ABSOLUTE)\n" ) - BuildTarget(GET "${__gtc_tgt_obj}" __gtc_dep_list depends) - CXXTarget(GET "${__gtc_tgt_obj}" __gtc_cxx_std cxx_standard) - CMaizeTarget(get_property "${__gtc_tgt_obj}" __gtc_version VERSION) - CMaizeTarget(get_property "${__gtc_tgt_obj}" __gtc_so_version SOVERSION) + # Determine library or executable + cpp_type_of(__gtc_tgt_obj_type "${__gtc_tgt_obj}") + cpp_implicitly_convertible( + __gtc_tgt_obj_is_lib "${__gtc_tgt_obj_type}" CMaizeLibrary + ) + # Create IMPORTED library of the correct type + if(__gtc_tgt_obj_is_lib) + CMaizeLibrary(GET "${__gtc_tgt_obj}" __gtc_lib_type type) + string(APPEND + __gtc_file_contents + " +# Create imported library target ${__gtc_namespace}${__gtc_target_name} +add_library(${__gtc_namespace}${__gtc_target_name} ${__gtc_lib_type} IMPORTED) +" + ) + # Assume it is an executable if it isn't a library + else() + string(APPEND + __gtc_file_contents + " +# Create imported executable target ${__gtc_namespace}${__gtc_target_name} +add_executable(${__gtc_namespace}${__gtc_target_name} IMPORTED) +" + ) + endif() + + # ----- Start collecting interface target properties ----- string(APPEND __gtc_file_contents " -# Create imported target ${__gtc_namespace}${__gtc_target_name} -add_library(${__gtc_namespace}${__gtc_target_name} SHARED IMPORTED) +set_target_properties(${__gtc_namespace}${__gtc_target_name} + PROPERTIES" + ) + + # Add interface compile features + CMaizeTarget(has_property + "${__gtc_tgt_obj}" + __gtc_tgt_obj_has_interface_compile_features + INTERFACE_COMPILE_FEATURES + ) + if(__gtc_tgt_obj_has_interface_compile_features) + CMaizeTarget(get_property + "${__gtc_tgt_obj}" + __gtc_tgt_obj_interface_compile_features + INTERFACE_COMPILE_FEATURES + ) + string(APPEND + __gtc_file_contents + " + INTERFACE_COMPILE_FEATURES \"${__gtc_tgt_obj_interface_compile_features}\"" + ) + endif() + + # Get interface compile definitions + CMaizeTarget(has_property "${__gtc_tgt_obj}" __gtc_has_interface_compile_definitions INTERFACE_COMPILE_DEFINITIONS) + if(__gtc_has_interface_compile_definitions) + CMaizeTarget(get_property "${__gtc_tgt_obj}" __gtc_interface_compile_definitions INTERFACE_COMPILE_DEFINITIONS) + string(APPEND + __gtc_file_contents + " + INTERFACE_COMPILE_DEFINITIONS \"${__gtc_interface_compile_definitions}\"" + ) + endif() -if(NOT \"${__gtc_cxx_std}\" STREQUAL \"\") - set_target_properties(${__gtc_namespace}${__gtc_target_name} PROPERTIES - INTERFACE_COMPILE_FEATURES \"cxx_std_${__gtc_cxx_std}\" + # Add include directories + # TODO: This should not be hard coded! + string(APPEND + __gtc_file_contents + " + INTERFACE_INCLUDE_DIRECTORIES \"\${PACKAGE_PREFIX_DIR}/include\"" ) -endif() -set_target_properties(${__gtc_namespace}${__gtc_target_name} PROPERTIES -INTERFACE_INCLUDE_DIRECTORIES \"\${PACKAGE_PREFIX_DIR}/include\" -INTERFACE_LINK_LIBRARIES " + string(APPEND + __gtc_file_contents + " + # TODO: Handle different configurations (Release, Debug, etc.) + # Import target \"${__gtc_namespace}${__gtc_target_name}\" for configuration \"???\" + IMPORTED_CONFIGURATIONS RELEASE" ) + # Collect interface link libraries + BuildTarget(GET "${__gtc_tgt_obj}" __gtc_dep_list depends) set(__gtc_interface_link_libraries) foreach(__gtc_dep_i ${__gtc_dep_list}) CMakePackageManager(GET "${self}" __gtc_dep_map dependencies) @@ -78,56 +140,76 @@ INTERFACE_LINK_LIBRARIES " list(APPEND __gtc_interface_link_libraries ${__gtc_dep_find_tgt_name}) endforeach() - string(APPEND - __gtc_file_contents - "\"${__gtc_interface_link_libraries}\" -)\n" - ) - - # Based on the shared library suffix, generate the correct versioned - # library name and soname that CMake will install - if ("${CMAKE_SHARED_LIBRARY_SUFFIX}" STREQUAL ".so") - set(__gtc_libname_w_version - "lib${__gtc_target_name}.so.${__gtc_version}" - ) - set(__gtc_soname "lib${__gtc_target_name}.so.${__gtc_so_version}") - elseif("${CMAKE_SHARED_LIBRARY_SUFFIX}" STREQUAL ".dylib") - set(__gtc_libname_w_version - "lib${__gtc_target_name}.${__gtc_version}.dylib" - ) - set(__gtc_soname - "lib${__gtc_target_name}.${__gtc_so_version}.dylib" - ) - elseif("${CMAKE_SHARED_LIBRARY_SUFFIX}" STREQUAL ".dll") - set(__gtc_libname_w_version - "${__gtc_target_name}.${__gtc_version}.dll" - ) - set(__gtc_soname - "${__gtc_target_name}.${__gtc_so_version}.dll" - ) - else() - string(APPEND __gtc_msg "Shared libraries with the") - string(APPEND __gtc_msg "${CMAKE_SHARED_LIBRARY_SUFFIX} suffix") - string(APPEND __gtc_msg "are not supported yet.") - cpp_raise( - UnsupportedLibraryType - "${__gtc_msg}" + # Add interface link libraries + list(LENGTH __gtc_interface_link_libraries __gtc_link_library_count) + if("${__gtc_link_library_count}" GREATER 0) + string(APPEND + __gtc_file_contents + " + INTERFACE_LINK_LIBRARIES \"${__gtc_interface_link_libraries}\"" ) endif() - CMakePackageManager(GET "${self}" __gtc_lib_prefix library_prefix) + # ----- End of collecting interface properties ----- string(APPEND __gtc_file_contents " +)" + ) + + # TODO: Are there other library types allowed here? Should this condition + # instead be 'NOT "${__gtc_lib_type}" STREQUAL "INTERFACE"'? + if("${__gtc_lib_type}" STREQUAL "SHARED" OR "${__gtc_lib_type}" STREQUAL "STATIC") + # Based on the shared library suffix, generate the correct versioned + # library name and soname that CMake will install + CMaizeTarget(get_property "${__gtc_tgt_obj}" __gtc_version VERSION) + CMaizeTarget(get_property "${__gtc_tgt_obj}" __gtc_so_version SOVERSION) + + if ("${CMAKE_SHARED_LIBRARY_SUFFIX}" STREQUAL ".so") + set(__gtc_libname_w_version + "lib${__gtc_target_name}.so.${__gtc_version}" + ) + set(__gtc_soname "lib${__gtc_target_name}.so.${__gtc_so_version}") + elseif("${CMAKE_SHARED_LIBRARY_SUFFIX}" STREQUAL ".dylib") + set(__gtc_libname_w_version + "lib${__gtc_target_name}.${__gtc_version}.dylib" + ) + set(__gtc_soname + "lib${__gtc_target_name}.${__gtc_so_version}.dylib" + ) + elseif("${CMAKE_SHARED_LIBRARY_SUFFIX}" STREQUAL ".dll") + set(__gtc_libname_w_version + "${__gtc_target_name}.${__gtc_version}.dll" + ) + set(__gtc_soname + "${__gtc_target_name}.${__gtc_so_version}.dll" + ) + else() + string(APPEND __gtc_msg "Shared libraries with the") + string(APPEND __gtc_msg "${CMAKE_SHARED_LIBRARY_SUFFIX} suffix") + string(APPEND __gtc_msg "are not supported yet.") + cpp_raise( + UnsupportedLibraryType + "${__gtc_msg}" + ) + endif() + endif() + + # Populate properties about exported objects if any are created + if("${__gtc_lib_type}" STREQUAL "SHARED" OR "${__gtc_lib_type}" STREQUAL "STATIC") + CMakePackageManager(GET "${self}" __gtc_lib_prefix library_prefix) + string(APPEND + __gtc_file_contents + " set(_CMAIZE_IMPORT_LOCATION \"\${PACKAGE_PREFIX_DIR}/${__gtc_lib_prefix}/${__gtc_target_name}/${__gtc_libname_w_version}\") -# TODO: Handle different configurations (Release, Debug, etc.) -# Import target \"${__gtc_namespace}${__gtc_target_name}\" for configuration \"???\" -set_property(TARGET ${__gtc_namespace}${__gtc_target_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) -set_target_properties(${__gtc_namespace}${__gtc_target_name} PROPERTIES -IMPORTED_LOCATION_RELEASE \"\${_CMAIZE_IMPORT_LOCATION}\" -IMPORTED_SONAME_RELEASE \"${__gtc_soname}\" + +set_target_properties(${__gtc_namespace}${__gtc_target_name} + PROPERTIES + IMPORTED_LOCATION_RELEASE \"\${_CMAIZE_IMPORT_LOCATION}\" + IMPORTED_SONAME_RELEASE \"${__gtc_soname}\" )\n" - ) + ) + endif() string(APPEND __gtc_file_contents diff --git a/cmake/cmaize/targets/build_target.cmake b/cmake/cmaize/targets/build_target.cmake index 8caa8bcd..352b4b37 100644 --- a/cmake/cmaize/targets/build_target.cmake +++ b/cmake/cmaize/targets/build_target.cmake @@ -64,7 +64,7 @@ cpp_class(BuildTarget CMaizeTarget) # cpp_attr(BuildTarget system_dependencies) #[[[ - # :type List[CMaizeTarget] + # :type: List[desc] # # Targets that are dependencies. #]] diff --git a/cmake/cmaize/targets/cmaize_interface_library.cmake b/cmake/cmaize/targets/cmaize_interface_library.cmake new file mode 100644 index 00000000..e0e12abb --- /dev/null +++ b/cmake/cmaize/targets/cmaize_interface_library.cmake @@ -0,0 +1,56 @@ +# Copyright 2025 CMakePP +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_guard() +include(cmakepp_lang/cmakepp_lang) +include(cmaize/targets/cmaize_library) + + +#[[[ +# Base class for CMaize interface libraries. Intended to be used as a parent or +# mixin to provide general, programming language-agnostic features for managing +# interface library targets. +#]] +cpp_class(CMaizeInterfaceLibrary CMaizeLibrary) + + #[[[ + # Creates a ``CMaizeInterfaceLibrary`` object to manage a target of the given name. + # + # .. note:: + # + # This does not create a corresponding CMake target, so any call that + # should interact with a target will fail if the target does not + # already exist. + # + # :param self: CMaizeInterfaceLibrary object constructed. + # :type self: CMaizeInterfaceLibrary + # :param tgt_name: Name of the target. This should not duplicate any other + # target name already in scope. + # :type tgt_name: desc or target + # + # :returns: ``self`` will be set to the newly constructed ``CMaizeInterfaceLibrary`` + # object. + # :rtype: CMaizeInterfaceLibrary + #]] + cpp_constructor(CTOR CMaizeInterfaceLibrary str) + function("${CTOR}" self _ctor_name) + + # Set the library type + CMaizeLibrary(CTOR "${self}" "${_ctor_name}") + CMaizeInterfaceLibrary(SET "${self}" type "INTERFACE") + + endfunction() + +cpp_end_class() + diff --git a/cmake/cmaize/targets/cmaize_library.cmake b/cmake/cmaize/targets/cmaize_library.cmake new file mode 100644 index 00000000..1a429b87 --- /dev/null +++ b/cmake/cmaize/targets/cmaize_library.cmake @@ -0,0 +1,71 @@ +# Copyright 2025 CMakePP +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_guard() +include(cmakepp_lang/cmakepp_lang) +include(cmaize/targets/cmaize_target) + + +#[[[ +# Base class for all CMaize libraries. Intended to be used as a parent or +# mixin to provide general, programming language-agnostic features for managing +# library targets. +#]] +cpp_class(CMaizeLibrary CMaizeTarget) + + #[[[ + # :type: desc + # + # Library type as defined by in CMake's `add_library + # `__ + # command. + # + # Defaults to the value of BUILD_SHARED_LIBS + #]] + cpp_attr(CMaizeLibrary type "${BUILD_SHARED_LIBS}") + + #[[[ + # Creates a ``CMaizeLibrary`` object to manage a target of the given name. + # + # .. note:: + # + # This does not create a corresponding CMake target, so any call that + # should interact with a target will fail if the target does not + # already exist. + # + # :param self: CMaizeLibrary object constructed. + # :type self: CMaizeLibrary + # :param tgt_name: Name of the target. This should not duplicate any other + # target name already in scope. + # :type tgt_name: desc or target + # + # :returns: ``self`` will be set to the newly constructed ``CMaizeLibrary`` + # object. + # :rtype: CMaizeLibrary + #]] + cpp_constructor(CTOR CMaizeLibrary str) + function("${CTOR}" self _ctor_name) + + CMaizeTarget(CTOR "${self}" "${_ctor_name}") + + if(BUILD_SHARED_LIBS) + CMaizeLibrary(SET "${self}" type "SHARED") + else() + CMaizeLibrary(SET "${self}" type "STATIC") + endif() + + endfunction() + +cpp_end_class() + diff --git a/cmake/cmaize/targets/cxx_interface_library.cmake b/cmake/cmaize/targets/cxx_interface_library.cmake index f8996dd5..7c4e4d37 100644 --- a/cmake/cmaize/targets/cxx_interface_library.cmake +++ b/cmake/cmaize/targets/cxx_interface_library.cmake @@ -13,9 +13,31 @@ # limitations under the License. include_guard() +include(cmaize/targets/cmaize_interface_library) include(cmaize/targets/cxx_library) -cpp_class(CXXInterfaceLibrary CXXLibrary) +cpp_class(CXXInterfaceLibrary CXXLibrary CMaizeInterfaceLibrary) + + #[[[ + # Creates a ``CXXInterfaceLibrary`` object to manage the named target. + # + # :param self: CXXInterfaceLibrary object constructed. + # :type self: CXXInterfaceLibrary + # :param tgt_name: Name of the target. This should not duplicate any other + # target name already in scope. + # :type tgt_name: desc or target + # + # :returns: ``self`` will be set to the newly constructed + # ``CXXInterfaceLibrary`` object. + # :rtype: CXXInterfaceLibrary + #]] + cpp_constructor(CTOR CXXInterfaceLibrary str) + function("${CTOR}" self _ctor_name) + + CXXLibrary(CTOR "${self}" "${_ctor_name}") + CMaizeInterfaceLibrary(CTOR "${self}" "${_ctor_name}") + + endfunction() #[[[ # Get the access level for the target. @@ -40,25 +62,6 @@ cpp_class(CXXInterfaceLibrary CXXLibrary) endfunction() - #[[[ - # Creates the interface library target with ``add_library()``. - # - # .. note:: - # - # Overrides ``BuildTarget(_create_target``. - # - # :param self: CXXInterfaceLibrary object - # :type self: CXXInterfaceLibrary - #]] - cpp_member(_create_target CXXInterfaceLibrary) - function("${_create_target}" self) - - CXXInterfaceLibrary(target "${self}" _it_name) - - add_library("${_it_name}" INTERFACE) - - endfunction() - #[[[ # CMake doesn't let interface libraries set their public headers, so # this function is a no-op. diff --git a/cmake/cmaize/targets/cxx_library.cmake b/cmake/cmaize/targets/cxx_library.cmake index 258f3a4d..c12bab34 100644 --- a/cmake/cmaize/targets/cxx_library.cmake +++ b/cmake/cmaize/targets/cxx_library.cmake @@ -13,9 +13,31 @@ # limitations under the License. include_guard() +include(cmaize/targets/cmaize_library) include(cmaize/targets/cxx_target) -cpp_class(CXXLibrary CXXTarget) +cpp_class(CXXLibrary CXXTarget CMaizeLibrary) + + #[[[ + # Creates a ``CXXLibrary`` object to manage the named target. + # + # :param self: CXXLibrary object constructed. + # :type self: CXXLibrary + # :param tgt_name: Name of the target. This should not duplicate any other + # target name already in scope. + # :type tgt_name: desc or target + # + # :returns: ``self`` will be set to the newly constructed + # ``CXXLibrary`` object. + # :rtype: CXXLibrary + #]] + cpp_constructor(CTOR CXXLibrary str) + function("${CTOR}" self _ctor_name) + + CXXTarget(CTOR "${self}" "${_ctor_name}") + CMaizeLibrary(CTOR "${self}" "${_ctor_name}") + + endfunction() #[[[ # Creates the library target with ``add_library()``. @@ -34,8 +56,10 @@ cpp_class(CXXLibrary CXXTarget) function("${_create_target}" self) CXXLibrary(target "${self}" _ct_name) + CXXLibrary(GET "${self}" _ct_lib_type type) + message(DEBUG "Library type of \"${_ct_name}\" is \"${_ct_lib_type}\"") - add_library("${_ct_name}") + add_library("${_ct_name}" "${_ct_lib_type}") endfunction() diff --git a/cmake/cmaize/targets/targets.cmake b/cmake/cmaize/targets/targets.cmake index 78112cfc..6122731a 100644 --- a/cmake/cmaize/targets/targets.cmake +++ b/cmake/cmaize/targets/targets.cmake @@ -16,6 +16,8 @@ include_guard() include(cmaize/targets/build_target) include(cmaize/targets/cmaize_target) +include(cmaize/targets/cmaize_library) +include(cmaize/targets/cmaize_interface_library) include(cmaize/targets/cxx_executable) include(cmaize/targets/cxx_interface_library) include(cmaize/targets/cxx_library) diff --git a/cmake/cmaize/user_api/add_library.cmake b/cmake/cmaize/user_api/add_library.cmake index 21bce626..39a555df 100644 --- a/cmake/cmaize/user_api/add_library.cmake +++ b/cmake/cmaize/user_api/add_library.cmake @@ -84,8 +84,8 @@ function(cmaize_add_library _cal_tgt_name) INSTALL_PATH "${_cal_install_path}" ) - # Loop over each dependency. This is currenjtly done by looking - # up the dependencies by name from the CMaizeProect, but later + # Loop over each dependency. This is currently done by looking + # up the dependencies by name from the CMaizeProject, but later # we should make each CMaize target hold references to its # dependencies cpp_get_global(_cal_top_proj CMAIZE_TOP_PROJECT) diff --git a/cmake/cmaize/user_api/dependencies/impl_/find_dependency.cmake b/cmake/cmaize/user_api/dependencies/impl_/find_dependency.cmake index 52327d2f..08164bc3 100644 --- a/cmake/cmaize/user_api/dependencies/impl_/find_dependency.cmake +++ b/cmake/cmaize/user_api/dependencies/impl_/find_dependency.cmake @@ -53,12 +53,15 @@ function(_cmaize_find_dependency _fd_tgt _fd_pm _fd_package_specs _fd_project _f _fob_get_package_manager(_fd_pm_tmp "${_fd_project}" "${_fd_pm_name}") message(STATUS "Attempting to find installed ${_fd_name}") + list(APPEND CMAKE_MESSAGE_INDENT " ") # Check if the package is already installed PackageManager(find_installed "${_fd_pm_tmp}" _fd_tgt_tmp "${_fd_package_specs_tmp}" ${ARGN} ) + list(POP_BACK CMAKE_MESSAGE_INDENT) + if(NOT "${_fd_tgt_tmp}" STREQUAL "") message(STATUS "${_fd_name} installation found") CMaizeProject(add_target diff --git a/cmake/cmaize/utilities/fetch_and_available.cmake b/cmake/cmaize/utilities/fetch_and_available.cmake index b598eb63..54dd143a 100644 --- a/cmake/cmaize/utilities/fetch_and_available.cmake +++ b/cmake/cmaize/utilities/fetch_and_available.cmake @@ -31,6 +31,8 @@ include(FetchContent) #]] macro(cmaize_fetch_and_available _faa_name) + message(VERBOSE "Fetching and making \"${_faa_name}\" available") + FetchContent_Declare("${_faa_name}" ${ARGN}) FetchContent_MakeAvailable("${_faa_name}")