Skip to content

Commit 2f698b6

Browse files
committed
Use imported CMake targets.
1 parent 8d3617b commit 2f698b6

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

cmake/FindCLN.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
find_library(CLN_LIBRARY NAMES cln)
22
include(FindPackageHandleStandardArgs)
33
find_package_handle_standard_args(CLN DEFAULT_MSG CLN_LIBRARY)
4+
5+
if(CLN_FOUND AND NOT TARGET CLN::CLN)
6+
add_library(CLN::CLN UNKNOWN IMPORTED)
7+
set_property(TARGET CLN::CLN PROPERTY IMPORTED_LOCATION ${CLN_LIBRARY})
8+
endif()

cmake/FindCVC4.cmake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ if (USE_CVC4)
1414
set(CVC4_LIBRARIES ${CVC4_LIBRARY})
1515

1616
if (CLN_FOUND)
17-
set(CVC4_LIBRARIES ${CVC4_LIBRARIES} ${CLN_LIBRARY})
17+
set(CVC4_LIBRARIES ${CVC4_LIBRARIES} CLN::CLN)
1818
endif ()
1919

2020
if (GMP_FOUND)
21-
set(CVC4_LIBRARIES ${CVC4_LIBRARIES} ${GMP_LIBRARY})
21+
set(CVC4_LIBRARIES ${CVC4_LIBRARIES} GMP::GMP)
2222
endif ()
23+
24+
if (NOT TARGET CVC4::CVC4)
25+
add_library(CVC4::CVC4 UNKNOWN IMPORTED)
26+
set_property(TARGET CVC4::CVC4 PROPERTY IMPORTED_LOCATION ${CVC4_LIBRARY})
27+
set_property(TARGET CVC4::CVC4 PROPERTY INTERFACE_LINK_LIBRARIES ${CVC4_LIBRARIES})
28+
set_property(TARGET CVC4::CVC4 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CVC4_INCLUDE_DIR})
29+
endif()
2330
endif()
2431
else()
2532
set(CVC4_FOUND FALSE)

cmake/FindGMP.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
find_library(GMP_LIBRARY NAMES gmp )
1+
find_library(GMP_LIBRARY NAMES gmp)
22
include(FindPackageHandleStandardArgs)
33
find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARY)
4+
5+
if(GMP_FOUND AND NOT TARGET GMP::GMP)
6+
add_library(GMP::GMP UNKNOWN IMPORTED)
7+
set_property(TARGET GMP::GMP PROPERTY IMPORTED_LOCATION ${GMP_LIBRARY})
8+
endif()

cmake/FindZ3.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
if (USE_Z3)
22
find_path(Z3_INCLUDE_DIR NAMES z3++.h PATH_SUFFIXES z3)
3-
find_library(Z3_LIBRARY NAMES z3 )
3+
find_library(Z3_LIBRARY NAMES z3)
44
include(FindPackageHandleStandardArgs)
55
find_package_handle_standard_args(Z3 DEFAULT_MSG Z3_LIBRARY Z3_INCLUDE_DIR)
6+
7+
if (NOT TARGET Z3::Z3)
8+
add_library(Z3::Z3 UNKNOWN IMPORTED)
9+
set_property(TARGET Z3::Z3 PROPERTY IMPORTED_LOCATION ${Z3_LIBRARY})
10+
set_property(TARGET Z3::Z3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR})
11+
endif()
612
else()
713
set(Z3_FOUND FALSE)
814
endif()
9-
# TODO: Create IMPORTED library for Z3.

cmake/jsoncpp.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ ExternalProject_Add(jsoncpp-project
5151
add_library(jsoncpp STATIC IMPORTED)
5252
file(MAKE_DIRECTORY ${JSONCPP_INCLUDE_DIR}) # Must exist.
5353
set_property(TARGET jsoncpp PROPERTY IMPORTED_LOCATION ${JSONCPP_LIBRARY})
54+
set_property(TARGET jsoncpp PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR})
5455
set_property(TARGET jsoncpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR})
5556
add_dependencies(jsoncpp jsoncpp-project)

libdevcore/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set(sources
1212
)
1313

1414
add_library(devcore ${sources})
15-
target_link_libraries(devcore PRIVATE jsoncpp ${Boost_FILESYSTEM_LIBRARIES} ${Boost_REGEX_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
15+
target_link_libraries(devcore PUBLIC jsoncpp ${Boost_FILESYSTEM_LIBRARIES} ${Boost_REGEX_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} Threads::Threads)
1616
target_include_directories(devcore PUBLIC "${CMAKE_SOURCE_DIR}")
1717
target_include_directories(devcore SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
1818
add_dependencies(devcore solidity_BuildInfo.h)

libsolidity/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ set(sources
5050

5151
find_package(Z3 QUIET)
5252
if (${Z3_FOUND})
53-
include_directories(${Z3_INCLUDE_DIR})
5453
add_definitions(-DHAVE_Z3)
5554
message("Z3 SMT solver found. This enables optional SMT checking with Z3.")
5655
set(z3_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/formal/Z3Interface.cpp")
@@ -60,7 +59,6 @@ endif()
6059

6160
find_package(CVC4 QUIET)
6261
if (${CVC4_FOUND})
63-
include_directories(${CVC4_INCLUDE_DIR})
6462
add_definitions(-DHAVE_CVC4)
6563
message("CVC4 SMT solver found. This enables optional SMT checking with CVC4.")
6664
set(cvc4_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/formal/CVC4Interface.cpp")
@@ -77,9 +75,9 @@ add_library(solidity ${sources} ${z3_SRCS} ${cvc4_SRCS})
7775
target_link_libraries(solidity PUBLIC yul evmasm langutil devcore ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
7876

7977
if (${Z3_FOUND})
80-
target_link_libraries(solidity PUBLIC ${Z3_LIBRARY})
78+
target_link_libraries(solidity PUBLIC Z3::Z3)
8179
endif()
8280

8381
if (${CVC4_FOUND})
84-
target_link_libraries(solidity PUBLIC ${CVC4_LIBRARIES})
82+
target_link_libraries(solidity PUBLIC CVC4::CVC4)
8583
endif()

0 commit comments

Comments
 (0)