Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ cpp_class(CMakePackageManager PackageManager)

PackageSpecification(GET "${_fi_package_specs}" _fi_pkg_name name)

message("Looking for ${_fi_pkg_name}")
message(STATUS "Looking for ${_fi_pkg_name}")

CMakePackageManager(register_dependency
"${self}"
Expand All @@ -199,24 +199,25 @@ cpp_class(CMakePackageManager PackageManager)
)

Dependency(find_dependency "${_fi_depend}" _fi_found)
Dependency(get "${_fi_depend}" _fi_dep_name name)
if(
NOT "${_fi_found}" OR
"${${_fi_pkg_name}_DIR}" STREQUAL "${_fi_pkg_name}_DIR-NOTFOUND"
"${${_fi_dep_name}_DIR}" STREQUAL "${_fi_dep_name}_DIR-NOTFOUND"
)
cpp_return("")
endif()

# Make sure that FIND_TARGET is populated with a name
if("${_fi_FIND_TARGET}" STREQUAL "")
if("${_fi_BUILD_TARGET}" STREQUAL "")
set(_fi_FIND_TARGET "${_fi_pkg_name}")
set(_fi_FIND_TARGET "${_fi_dep_name}")
else()
set(_fi_FIND_TARGET "${_fi_BUILD_TARGET}")
endif()
endif()

# Create an installed target
set(_fi_depend_root_path "${${_fi_pkg_name}_DIR}")
set(_fi_depend_root_path "${${_fi_dep_name}_DIR}")
InstalledTarget(ctor
_fi_tgt "${_fi_FIND_TARGET}" "${_fi_depend_root_path}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ macro(
__gpc_pkg_name
)


message(VERBOSE "Generating package config for ${__gpc_pkg_name}")
list(APPEND CMAKE_MESSAGE_INDENT " ")

set(__gpc_targets ${ARGN})

_cmaize_generated_by_cmaize(__gpc_file_contents)
Expand All @@ -38,6 +40,11 @@ macro(
CMaizeProject(get_target
"${__gpc_proj}" __gpc_tgt_obj "${__gpc_targets_i}"
)

CMaizeTarget(target "${__gpc_tgt_obj}" __gpc_tgt_name)
message(VERBOSE "Processing target: \"${__gpc_tgt_name}\"")
list(APPEND CMAKE_MESSAGE_INDENT " ")

BuildTarget(GET "${__gpc_tgt_obj}" __gpc_tgt_deps depends)

list(LENGTH __gpc_tgt_deps __gpc_tgt_deps_len)
Expand All @@ -56,7 +63,7 @@ macro(
endif()

foreach(__gpc_tgt_deps_i ${__gpc_tgt_deps})
message(DEBUG "Processing dependency: ${__gpc_tgt_deps_i}")
message(VERBOSE "Processing dependency: \"${__gpc_tgt_deps_i}\"")

# Skip dependency processing if this is not a target managed
# by the CMaize project
Expand All @@ -68,7 +75,7 @@ macro(
)
if(NOT __gpc_is_cmaize_tgt)
message(
DEBUG
VERBOSE
"Skipping ${__gpc_tgt_deps_i}. It is not target "
"managed by CMaize."
)
Expand All @@ -80,7 +87,7 @@ macro(
cpp_contains(_gpc_dep_is_proj_tgt "${__gpc_tgt_deps_i}" "${__gpc_targets}")
if(_gpc_dep_is_proj_tgt)
message(
DEBUG
VERBOSE
"Skipping ${__gpc_tgt_deps_i}. It is a target defined "
"by this project."
)
Expand All @@ -90,9 +97,26 @@ macro(
# Check if it is a dependency to be built and redirect the
# installation to the ``external`` directory
CMaizeProject(get_target
"${__gpc_proj}" __gpc_tgt_deps_i_obj "${__gpc_tgt_deps_i}"
"${__gpc_proj}" __gpc_tgt_deps_i_obj "${__gpc_tgt_deps_i}" ALL
)

# Skip dependencies that are just empty interface libraries. This
# is the type for a dummy target for optional dependencies that
# were not enabled in ``cmaize_find*_optional_dependency()``
CMaizeTarget(target "${__gpc_tgt_deps_i_obj}" __gpc_tgt_deps_i_name)
get_target_property(__gpc_tgt_deps_i_type "${__gpc_tgt_deps_i_name}" TYPE)
CMaizeTarget(GET "${__gpc_tgt_deps_i_obj}" _gpc_tgt_depts_i_install_path install_path)
if(("${__gpc_tgt_deps_i_type}" STREQUAL "INTERFACE_LIBRARY") AND ("${_gpc_tgt_depts_i_install_path}" STREQUAL ""))
message(
VERBOSE
"Skipping ${__gpc_tgt_deps_i}. It is an empty interface "
"library target."
)
continue()
endif()

list(APPEND CMAKE_MESSAGE_INDENT " ")

CMakePackageManager(GET "${self}" __gpc_dependencies dependencies)
cpp_map(GET "${__gpc_dependencies}" __gpc_dep_obj "${__gpc_tgt_deps_i}")

Expand All @@ -114,7 +138,11 @@ macro(
"find_dependency(${__gpc_tgt_deps_i} COMPONENTS ${__gpc_dep_build_tgt_name})\n"
)
endif()

list(POP_BACK CMAKE_MESSAGE_INDENT)
endforeach()

list(POP_BACK CMAKE_MESSAGE_INDENT)
endforeach()

# Add a space between the dependency imports and component imports
Expand Down Expand Up @@ -167,6 +195,7 @@ macro(
"${CMAKE_CURRENT_BINARY_DIR}/${__gpc_pkg_name}Config.cmake.in"
)

list(POP_BACK CMAKE_MESSAGE_INDENT)
cpp_return("${__gpc_output_file}")

endmacro()
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ function(_cpm_install_package_impl self _ip_pkg_name)

# Actually append the aggregated paths to the current target's
# INSTALL_RPATH
CMaizeTarget(get_property "${_ip_tgt_obj_i}" _install_rpath INSTALL_RPATH)
CMaizeTarget(has_property "${_ip_tgt_obj_i}" _has_install_rpath INSTALL_RPATH)
if(_has_install_rpath)
CMaizeTarget(get_property "${_ip_tgt_obj_i}" _install_rpath INSTALL_RPATH)
endif()
list(APPEND _install_rpath ${_dep_install_path})
list(APPEND _install_rpath ${_dep_install_rpath})
CMaizeTarget(set_property "${_ip_tgt_obj_i}" INSTALL_RPATH "${_install_rpath}")
Expand Down
5 changes: 1 addition & 4 deletions cmake/cmaize/project/cmaize_project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ cpp_class(CMaizeProject)
# :param _ct_target_name: Identifying name for the target. This can match
# name of either the CMake target or CMaizeTarget
# object, but is required to do match them.
# :type _ct_target_name: desc
# :type _ct_target_name: desc or target
# :param **kwargs: Additional keyword arguments may be necessary.
#
# :Keyword Arguments:
Expand All @@ -360,9 +360,6 @@ cpp_class(CMaizeProject)
# * **ALL** (*bool*) --
# Flag to indicate that both the build and installed targets should
# be checked.
# * **NAME** (*desc* or *target*) --
# Identifying name for a target contained in the current Cmaize
# project. This keyword argument is **required**.
#
# :returns: CMaizeTarget found (TRUE) or not (FALSE).
# :rtype: bool
Expand Down
20 changes: 16 additions & 4 deletions cmake/cmaize/targets/cxx_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ cpp_class(CXXTarget BuildTarget)
CXXTarget(_access_level "${self}" _scf_access_level)

if(NOT "${_scf_cxx_std}" STREQUAL "")
message(VERBOSE "Setting CXX standard to \"cxx_std_${_scf_cxx_std}\"")
target_compile_features(
"${_scf_tgt_name}"
"${_scf_access_level}" "cxx_std_${_scf_cxx_std}"
"${_scf_access_level}"
"cxx_std_${_scf_cxx_std}"
)
endif()
endfunction()
Expand Down Expand Up @@ -185,7 +187,9 @@ cpp_class(CXXTarget BuildTarget)

# Set up public includes
CXXTarget(_access_level "${self}" _sid_access_level)
message(VERBOSE "Setting build interface include directories to")
foreach(_sid_inc_dir_i ${_sid_inc_dirs})
message(VERBOSE " ${_sid_inc_dir_i}")
target_include_directories(
"${_sid_tgt_name}"
"${_sid_access_level}"
Expand All @@ -194,18 +198,23 @@ cpp_class(CXXTarget BuildTarget)
endforeach()

# Set up installation includes
message(VERBOSE "Setting install interface include directories to")
message(VERBOSE " include")
target_include_directories(
"${_sid_tgt_name}"
"${_sid_access_level}"
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include>
)

if(NOT "${_sid_access_level}" STREQUAL "INTERFACE")
message(VERBOSE "Setting private header include directories to")
message(VERBOSE " ${_sid_src_dir}")

# Set up private header includes
target_include_directories(
"${_sid_tgt_name}"
PRIVATE
"${_sid_src_dir}"
"${_sid_src_dir}"
)
endif()

Expand All @@ -228,9 +237,10 @@ cpp_class(CXXTarget BuildTarget)
# underlying target name
cmaize_replace_project_targets(_sll_deps ${_sll_deps})

message(VERBOSE "Registering link library dependencies")
CXXTarget(_access_level "${self}" _sll_access_level)
foreach(_sll_dep_i ${_sll_deps})
message(DEBUG "Registering ${_sll_dep_i} as a dependency of ${_sll_name}.")
message(VERBOSE " ${_sll_dep_i}")
target_link_libraries(
"${_sll_name}" "${_sll_access_level}" "${_sll_dep_i}"
)
Expand All @@ -251,6 +261,7 @@ cpp_class(CXXTarget BuildTarget)
CXXTarget(GET "${self}" _sph_inc_files includes)

# TODO: This may hang if '_sph_inc_files' is empty
message(VERBOSE "Setting PUBLIC_HEADER to \"${_sph_inc_files}\"")
CXXTarget(set_property "${self}" PUBLIC_HEADER "${_sph_inc_files}")

endfunction()
Expand All @@ -269,6 +280,7 @@ cpp_class(CXXTarget BuildTarget)
CXXTarget(GET "${self}" _ss_src_files sources)

# Sources for a CXX target should be private
message(VERBOSE "Setting sources to \"${_ss_src_files}\"")
target_sources(
"${_ss_tgt_name}"
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions cmake/cmaize/targets/installed_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cpp_class(InstalledTarget CMaizeTarget)
endif()

InstalledTarget(SET "${self}" root_path "${_ctor_root}")
CMaizeTarget(SET "${self}" install_path "${_ctor_root}")

endfunction()

Expand Down
45 changes: 37 additions & 8 deletions cmake/cmaize/user_api/add_library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ include(cmaize/utilities/replace_project_targets)
#]]
function(cmaize_add_library _cal_tgt_name)

message(VERBOSE "Registering library target: ${_cal_tgt_name}")
message(VERBOSE "Creating library target: ${_cal_tgt_name}")
list(APPEND CMAKE_MESSAGE_INDENT " ")

set(_cal_one_value_args LANGUAGE)
cmake_parse_arguments(_cal "" "${_cal_one_value_args}" "" ${ARGN})

# Default to CXX if no language is given
if("${_cal_LANGUAGE}" STREQUAL "")
message(VERBOSE "No language set, enabling \"CXX\"")
set(_cal_LANGUAGE "CXX")
endif()

Expand Down Expand Up @@ -82,24 +84,32 @@ function(cmaize_add_library _cal_tgt_name)
INSTALL_PATH "${_cal_install_path}"
)

# Loop over each dependency. This is currently done by looking
# up the dependencies by name from the CMaizeProject, but later
# Loop over each dependency. This is currenjtly done by looking
# up the dependencies by name from the CMaizeProect, but later
# we should make each CMaize target hold references to its
# dependencies
cpp_get_global(_cal_top_proj CMAIZE_TOP_PROJECT)
BuildTarget(GET "${_cal_tgt_obj}" _dep_list depends)

message(VERBOSE "Building INSTALL_RPATH")
list(APPEND CMAKE_MESSAGE_INDENT " ")

foreach(dependency ${_dep_list})
# Fetch the dependency's target object
CMaizeProject(get_target
"${_cal_top_proj}" _dep_tgt_obj "${dependency}"
"${_cal_top_proj}" _dep_tgt_obj "${dependency}" ALL
)

# Skip the dependency if it is not managed by CMaize, since
# those won't have install path information
if("${_dep_tgt_obj}" STREQUAL "")
message(VERBOSE "Skipping \"${dependency}\" not managed by CMaize.")
continue()
endif()

message(VERBOSE "From ${dependency}")
list(APPEND CMAKE_MESSAGE_INDENT " ")

# Get the install path for the dependency
CMaizeTarget(GET "${_dep_tgt_obj}" _dep_install_path install_path)

Expand Down Expand Up @@ -134,13 +144,30 @@ function(cmaize_add_library _cal_tgt_name)
get_property "${_cal_tgt_obj}" _install_rpath INSTALL_RPATH
)
endif()
list(APPEND _install_rpath ${_dep_install_path})
list(APPEND _install_rpath ${_dep_install_rpath})
CMaizeTarget(
set_property "${_cal_tgt_obj}" INSTALL_RPATH "${_install_rpath}"

if(NOT "${_dep_install_path}" STREQUAL "")
message(VERBOSE "Adding \"${_dep_install_path}\"")
list(APPEND _install_rpath ${_dep_install_path})
else()
message(VERBOSE "No install path to append")
endif()

if(NOT "${_dep_install_rpath}" STREQUAL "")
message(VERBOSE "Adding \"${_dep_install_rpath}\"")
list(APPEND _install_rpath ${_dep_install_rpath})
else()
message(VERBOSE "No install RPATH to append")
endif()

CMaizeTarget(set_property
"${_cal_tgt_obj}" INSTALL_RPATH "${_install_rpath}"
)

list(POP_BACK CMAKE_MESSAGE_INDENT)
endforeach()

list(POP_BACK CMAKE_MESSAGE_INDENT)
list(POP_BACK CMAKE_MESSAGE_INDENT)
endfunction()

#[[[
Expand Down Expand Up @@ -192,8 +219,10 @@ function(cmaize_add_cxx_library _cacl_tgt_obj _cacl_tgt_name)
# is a library or interface library
list(LENGTH _cacl_source_files _cacl_source_files_n)
if("${_cacl_source_files_n}" GREATER 0)
message(VERBOSE "Creating \"${_cacl_tgt_name}\" as a CXXLibrary")
CXXLibrary(CTOR _cacl_lib_obj "${_cacl_tgt_name}")
else()
message(VERBOSE "Creating \"${_cacl_tgt_name}\" as a CXXInterfaceLibrary")
CXXInterfaceLibrary(CTOR _cacl_lib_obj "${_cacl_tgt_name}")
endif()

Expand Down
6 changes: 4 additions & 2 deletions cmake/cmaize/user_api/dependencies/find_dependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ include(cmaize/user_api/dependencies/impl_/find_dependency)
# :param **kwargs: Keyword arguments describing the behavior of the search. See
# the documentation for _fob_parse_arguments for a complete list.
#
# :raises UNKNOWN_PM: When ``pm_name`` does not correspond to a known package
# manager. Strong throw guarantee.
# :raises PACKAGE_NOT_FOUND: CMaize was unable to locate the package specified.
# Strong throw guarantee.
# :raises UNKNOWN_PM: ``PACKAGE_MANAGER`` does not correspond to a known
# package manager. Strong throw guarantee.
#]]
function(cmaize_find_dependency _cfd_name)

Expand Down
Loading