blender/intern/atomic/CMakeLists.txt
Ray Molenkamp f0ee4c3ffe Cleanup: Cmake: use alias target for bf_intern_atomic
This introduces an alias target `bf::intern::atomic` for
`bf_intern_atomic`. This has the following benefits:

- Any target name with `::` in it will be recognized as an actual
target by cmake, rather than a library name it may not know about.
and will be validated by cmake to exist. Which means if you make
a typo in the LIB section, CMake will error out telling you it
doesn't know about this specific target rather than passing it on
to the build system, where you'll either get build or linker errors
because of said typo.

- Given there is quite a cleanup still to do in the build system,
it won't always be obvious which targets have been updated to
modern targets and which still need to be done. Having a namespaced
target name is a good indicator there.

Pull Request: https://projects.blender.org/blender/blender/pulls/109784
2023-07-07 15:37:02 +02:00

45 lines
1.1 KiB
CMake

# SPDX-FileCopyrightText: 2020 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(INC
.
)
set(INC_SYS
)
add_library(bf_intern_atomic INTERFACE)
target_include_directories(bf_intern_atomic INTERFACE .)
add_library(bf::intern::atomic ALIAS bf_intern_atomic)
# CMake 3.19+ allows one to populate the interface library with
# source files to show in the IDE, for people on older CMake versions
# these headers will be visible in the bf_intern_guardedalloc project
# where they historically have been.
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
set(SRC
atomic_ops.h
intern/atomic_ops_ext.h
intern/atomic_ops_msvc.h
intern/atomic_ops_unix.h
intern/atomic_ops_utils.h
)
target_sources(bf_intern_atomic PRIVATE ${SRC})
blender_source_group(bf_intern_atomic ${SRC})
endif()
if(WITH_GTESTS)
set(TEST_SRC
tests/atomic_test.cc
)
set(TEST_INC
)
set(TEST_LIB
PRIVATE bf_intern_atomic
)
include(GTestTesting)
blender_add_test_executable(atomic "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
endif()