Skip to content

Commit 673ddef

Browse files
committed
[cmake] Ensure code is compiled with -Werror in dev mode
The recent hotfix in #800 requiring the v0.7.1 tag was fixing an instance of code not compiling when `-Werror` is specified. We do already specify `-Werror` with `UR_DEVELOPER_MODE=ON` in the GitHub Actions, however the `ur_common` library was not being compiled explicitly with this flag. As setup prior to this patch `ur_common` was an interface library. This means the source files are not compiled into their own static library but instead included in any targets which "link" it. This patch changes the `ur_common` into a static library that is always compiled into a static library avoiding recompiling the source files in each target which makes use of it. Adapters will now link with the static library instead of including its source files into their own targets build steps. Additionally, the test suite `test-loader-config` was also updated to use `add_ur_exectuable` and thus respect the flags set when `UR_DEVELOPER_MODE=ON`.
1 parent ecdd28f commit 673ddef

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

source/common/CMakeLists.txt

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,25 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
add_library(ur_common INTERFACE)
6+
add_subdirectory(unified_malloc_framework)
7+
add_subdirectory(umf_pools)
8+
9+
add_ur_library(ur_common STATIC
10+
umf_helpers.hpp
11+
ur_pool_manager.hpp
12+
$<$<PLATFORM_ID:Windows>:windows/ur_lib_loader.cpp>
13+
$<$<PLATFORM_ID:Linux,Darwin>:linux/ur_lib_loader.cpp>
14+
)
715
add_library(${PROJECT_NAME}::common ALIAS ur_common)
816

9-
target_include_directories(ur_common INTERFACE
17+
target_include_directories(ur_common PUBLIC
1018
${CMAKE_CURRENT_SOURCE_DIR}
1119
${CMAKE_SOURCE_DIR}/include
1220
)
1321

14-
add_subdirectory(unified_malloc_framework)
15-
add_subdirectory(umf_pools)
16-
target_link_libraries(ur_common INTERFACE unified_malloc_framework disjoint_pool ${CMAKE_DL_LIBS} ${PROJECT_NAME}::headers)
17-
18-
if(WIN32)
19-
target_sources(ur_common
20-
INTERFACE
21-
${CMAKE_CURRENT_SOURCE_DIR}/windows/ur_lib_loader.cpp
22-
umf_helpers.hpp ur_pool_manager.hpp
23-
)
24-
else()
25-
target_sources(ur_common
26-
INTERFACE
27-
${CMAKE_CURRENT_SOURCE_DIR}/linux/ur_lib_loader.cpp
28-
umf_helpers.hpp ur_pool_manager.hpp
29-
)
30-
endif()
22+
target_link_libraries(ur_common PUBLIC
23+
unified_malloc_framework
24+
disjoint_pool
25+
${CMAKE_DL_LIBS}
26+
${PROJECT_NAME}::headers
27+
)

test/loader/loader_config/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
add_executable(test-loader-config
6+
add_ur_executable(test-loader-config
77
urLoaderConfigCreate.cpp
88
urLoaderConfigGetInfo.cpp
99
urLoaderConfigEnableLayer.cpp

0 commit comments

Comments
 (0)