Skip to content

Commit 7b2af64

Browse files
i#1652: Update CMake CMP0024 to modern behavior (#2272)
Removes the setting of CMP0024 to OLD. Guards the inclusion of the drmf export file in a new DrMemory_INTERNAL variable. Adds a build-and-test test "drmf_proj" to ensure an external user can build using our exported config files. Fixes #1652
1 parent b7f12a0 commit 7b2af64

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed

CMakeLists.txt

+24
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,8 @@ add_asm_target(common/${asm_file} asm_utils_src asm_utils_tgt ""
10821082

10831083
##################################################
10841084

1085+
set(DrMemory_INTERNAL ON) # Do not import exported targets.
1086+
10851087
if (ANDROID)
10861088
# We cache this for us in sub-projects like framework/samples/
10871089
set(TOP_BINARY_DIR ${PROJECT_BINARY_DIR})
@@ -1930,6 +1932,28 @@ endif (TOOL_DR_MEMORY)
19301932
if (BUILD_TOOL_TESTS)
19311933
add_subdirectory(tests/framework)
19321934

1935+
# Test using our exported config.
1936+
if (DEBUG)
1937+
set(debug_cfg -DCMAKE_BUILD_TYPE=Debug)
1938+
else ()
1939+
set(debug_cfg -DCMAKE_BUILD_TYPE=RelWithDebInfo)
1940+
endif ()
1941+
set(drmf_bindir "${PROJECT_BINARY_DIR}/framework/samples")
1942+
file(COPY "${PROJECT_SOURCE_DIR}/framework/samples/strace.c"
1943+
DESTINATION "${drmf_bindir}")
1944+
add_test(drmf_proj ${CMAKE_CTEST_COMMAND}
1945+
--build-and-test "${drmf_bindir}"
1946+
"${PROJECT_BINARY_DIR}/tests/drmf_proj"
1947+
--build-generator ${CMAKE_GENERATOR}
1948+
--build-project DRMF_samples # Needed for VS generators.
1949+
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
1950+
--build-options ${debug_cfg} -DDrMemoryFramework_DIR:PATH=${framework_dir}
1951+
-DDynamoRIO_DIR:PATH=${DynamoRIO_DIR})
1952+
if (UNIX AND X86 AND NOT X64)
1953+
set_tests_properties(drmf_proj PROPERTIES ENVIRONMENT
1954+
"CFLAGS=-m32;CXXFLAGS=-m32")
1955+
endif ()
1956+
19331957
if (TOOL_DR_MEMORY)
19341958
# unit tests
19351959
add_executable(unit_tests ${srcs})

drsyscall/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ use_DynamoRIO_extension(drsyscall drsyms)
126126
set_library_version(drsyscall ${DRMF_VERSION_MAJOR_MINOR})
127127
configure_drsyscall_target(drsyscall)
128128
export_drsyscall_target(drsyscall "drmgr" "drsyms")
129+
# Make a build-dir copy for the drmf_proj test.
130+
configure_file(drsyscall.h "${framework_incdir}/drsyscall.h" @ONLY)
129131
install(FILES drsyscall.h DESTINATION ${DRMF_INSTALL_INC})
130132

131133
# Since the license is LGPL, SHARED and not STATIC by default.

framework/drmf.cmake.in

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# **********************************************************
2-
# Copyright (c) 2012-2015 Google, Inc. All rights reserved.
2+
# Copyright (c) 2012-2020 Google, Inc. All rights reserved.
33
# **********************************************************
44

55
# Dr. Memory: the memory debugger
@@ -21,13 +21,6 @@
2121
# Be sure to prefix all global vars with "drmf_" to avoid conflicts
2222
# with the containing project.
2323

24-
cmake_policy(PUSH)
25-
if ("${CMAKE_VERSION}" VERSION_EQUAL "3.0" OR
26-
"${CMAKE_VERSION}" VERSION_GREATER "3.0")
27-
# XXX i#1652: update to cmake 2.8.12's better handling of interface exports
28-
cmake_policy(SET CMP0024 OLD)
29-
endif ()
30-
3124
if (${CMAKE_CXX_SIZEOF_DATA_PTR} EQUAL 4)
3225
set(drmf_is_x64 OFF)
3326
elseif (${CMAKE_C_SIZEOF_DATA_PTR} EQUAL 4)
@@ -45,5 +38,6 @@ endif (drmf_is_x64)
4538
# Be sure to not conflict w/ DR's "cwd" var (i#1105)
4639
get_filename_component(drmf_cwd "${CMAKE_CURRENT_LIST_FILE}" PATH)
4740

48-
include(${drmf_cwd}/DRMFTarget${drmf_bits}.cmake)
49-
cmake_policy(POP)
41+
if (NOT DrMemory_INTERNAL)
42+
include(${drmf_cwd}/DRMFTarget${drmf_bits}.cmake)
43+
endif ()

framework/samples/CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ else ()
113113
string(REGEX REPLACE "# NON-COMBINED" "" string "${string}")
114114
endif ()
115115
string(REGEX REPLACE "# START NON-EXPORTED SECTION.*$" "" string "${string}")
116-
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeLists-public.txt.in" "${string}")
117-
configure_file("${CMAKE_CURRENT_BINARY_DIR}/CMakeLists-public.txt.in"
118-
"${CMAKE_CURRENT_BINARY_DIR}/CMakeLists-public.txt"
116+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt.in" "${string}")
117+
configure_file("${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt.in"
118+
"${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt"
119119
@ONLY)
120120

121121
if (BUILD_TOOL_TESTS)
@@ -148,8 +148,8 @@ endif (X64)
148148

149149
install(TARGETS strace DESTINATION ${INSTALL_SAMPLES_BIN})
150150
install(FILES strace.c DESTINATION ${INSTALL_SAMPLES})
151-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CMakeLists-public.txt"
152-
DESTINATION "${INSTALL_SAMPLES}" RENAME CMakeLists.txt)
151+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt"
152+
DESTINATION "${INSTALL_SAMPLES}")
153153

154154
install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/
155155
DESTINATION ${INSTALL_SAMPLES_BIN}

make/policies.cmake

-8
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,5 @@
1818
# License along with this library; if not, write to the Free Software
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020

21-
if ("${CMAKE_VERSION}" VERSION_EQUAL "3.0" OR
22-
"${CMAKE_VERSION}" VERSION_GREATER "3.0")
23-
# TODO i#1652: switch to ctest --build_and_test.
24-
# (Unfortunately this is printed for multiple subdirectories: passing
25-
# "-Wno-deprecated" to cmake will silence it.)
26-
cmake_policy(SET CMP0024 OLD)
27-
endif ()
28-
2921
# i#1418: We are updated to the new scheme.
3022
cmake_policy(SET CMP0022 NEW)

0 commit comments

Comments
 (0)