Skip to content

Commit 58e367a

Browse files
authored
Update Build (#753)
* Use file sets for headers to improve IDE integration * bump dependencies * Deprecate PHASAR_EXPERIMENTAL_CXX20 + modernize boost finding via find_package(CONFIG) * update gtest version * Somplify headers inclusion + fix boost include for installed phasar * Revisit examples and docs
1 parent f9e96b3 commit 58e367a

File tree

12 files changed

+62
-58
lines changed

12 files changed

+62
-58
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ build/*
4646
.idea/*
4747

4848
# cache
49-
.cache/*
49+
.cache/
5050

5151
##### ignored files
5252

CMakeLists.txt

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.16)
1+
cmake_minimum_required (VERSION 3.14...3.28)
22

33
# Avoid IPO/LTO Warnings:
44
cmake_policy(SET CMP0069 NEW)
@@ -39,6 +39,10 @@ else()
3939
endif()
4040

4141
option(PHASAR_EXPERIMENTAL_CXX20 "Build phasar in C++20 mode. This is an experimental feature" OFF)
42+
if(PHASAR_EXPERIMENTAL_CXX20)
43+
message(DEPRECATION "The option PHASAR_EXPERIMENTAL_CXX20 is deprecated and will be removed in a future version of PhASAR. Use CMAKE_CXX_STANDARD=20 instead.")
44+
set(CMAKE_CXX_STANDARD 20)
45+
endif()
4246

4347
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
4448
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -258,24 +262,13 @@ else()
258262
set(PHASAR_CONFIG_INSTALL_DIR "${PHASAR_CUSTOM_CONFIG_INSTALL_DIR}")
259263
endif()
260264

261-
262-
# Headers
263-
264-
add_library(phasar_interface INTERFACE)
265-
target_include_directories(phasar_interface
266-
INTERFACE
267-
$<BUILD_INTERFACE:${PHASAR_SRC_DIR}/include/> # The regular include folder
268-
$<BUILD_INTERFACE:${PHASAR_BINARY_DIR}/include/> # The location of phasar-config.h
269-
$<INSTALL_INTERFACE:include/> # The installed include folder
270-
)
271-
272265
### Adding external libraries
273266

274267
# Threads
275268
find_package(Threads)
276269

277270
# Boost
278-
find_package(Boost 1.65.1 COMPONENTS graph REQUIRED)
271+
find_package(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG)
279272

280273
# Disable clang-tidy for the external projects
281274
set(CMAKE_CXX_CLANG_TIDY "")
@@ -291,10 +284,11 @@ if (NOT PHASAR_IN_TREE)
291284
if(PHASAR_BUILD_UNITTESTS AND NOT TARGET gtest)
292285
include(FetchContent)
293286

287+
set(INSTALL_GTEST OFF)
294288
FetchContent_Declare(
295289
googletest
296290
GIT_REPOSITORY https://github.com/google/googletest.git
297-
GIT_TAG v1.13.0
291+
GIT_TAG v1.16.0
298292
)
299293
FetchContent_MakeAvailable(googletest)
300294
endif()
@@ -368,9 +362,6 @@ if(NOT PHASAR_IN_TREE)
368362
add_definitions(${LLVM_DEFINITIONS_LIST})
369363
endif()
370364

371-
# Installed config
372-
configure_file(config.h.in include/phasar/Config/phasar-config.h @ONLY)
373-
374365
# Warnings
375366
option(PHASAR_ENABLE_WARNINGS "Enable warnings" ${PHASAR_BUILD_OPTIONAL_TARGETS_DEFAULT})
376367
if (PHASAR_ENABLE_WARNINGS)
@@ -381,6 +372,18 @@ if (PHASAR_ENABLE_WARNINGS)
381372
endif()
382373
endif (PHASAR_ENABLE_WARNINGS)
383374

375+
376+
# Headers
377+
add_library(phasar_interface INTERFACE)
378+
file(GLOB_RECURSE PHASAR_PUBLIC_HEADERS include/*.h include/*.def)
379+
configure_file(config.h.in include/phasar/Config/phasar-config.h @ONLY)
380+
381+
target_sources(phasar_interface INTERFACE
382+
FILE_SET HEADERS
383+
BASE_DIRS "${PHASAR_SRC_DIR}/include" "${PHASAR_BINARY_DIR}/include"
384+
FILES ${PHASAR_PUBLIC_HEADERS} "${PHASAR_BINARY_DIR}/include/phasar/Config/phasar-config.h"
385+
)
386+
384387
# Some preprocessor symbols that need to be available in phasar sources, but should not be installed
385388
add_cxx_compile_definitions(PHASAR_SRC_DIR="${CMAKE_SOURCE_DIR}")
386389
add_cxx_compile_definitions(PHASAR_BUILD_DIR="${CMAKE_BINARY_DIR}")
@@ -425,25 +428,10 @@ set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Install dir of lib
425428
# Install targets of phasar-cli, other executables, and libraries are to be
426429
# found in the individual subdirectories of tools/
427430

428-
# Install Phasar include directory
429-
install(DIRECTORY include/
430-
DESTINATION include
431-
FILES_MATCHING
432-
PATTERN "*.def"
433-
PATTERN "*.h"
434-
)
435-
436-
# Install the config file
437-
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/phasar/Config/
438-
DESTINATION include/phasar/Config
439-
FILES_MATCHING
440-
PATTERN "*.def"
441-
PATTERN "*.h"
442-
)
443-
444431
if(NOT PHASAR_IN_TREE)
445432
install(TARGETS phasar_interface
446433
EXPORT PhasarExports
434+
FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
447435
)
448436
if (NOT PHASAR_USE_CONAN)
449437
# Install the export-set containing all the phasar targets
@@ -454,13 +442,14 @@ if(NOT PHASAR_IN_TREE)
454442
)
455443
install(EXPORT ${PHASAR_DEPS_EXPORT_SET}
456444
FILE ${PHASAR_DEPS_EXPORT_SET}.cmake
457-
NAMESPACE phasar::
445+
NAMESPACE phasar::deps::
458446
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/phasar"
459447
)
460448
endif()
461449
else()
462450
install(TARGETS phasar_interface
463451
EXPORT LLVMExports
452+
FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
464453
)
465454
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS phasar_interface)
466455
endif()
@@ -470,6 +459,7 @@ install(DIRECTORY utils/
470459
DESTINATION bin
471460
FILES_MATCHING
472461
PATTERN "CodeGen" EXCLUDE # CodeGen does not contain files to install
462+
PATTERN "conan" EXCLUDE # Don't install conan utils
473463
PATTERN "phasar-*"
474464
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
475465
GROUP_EXECUTE GROUP_READ

Config.cmake.in

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ set_and_check(PHASAR_LIBRARY_DIR "@PACKAGE_LIBRARY_INSTALL_DIR@")
66

77
include (CMakeFindDependencyMacro)
88

9+
set(PHASAR_LLVM_VERSION @PHASAR_LLVM_VERSION@)
10+
911
include("${CMAKE_CURRENT_LIST_DIR}/PhasarDepsExports.cmake")
10-
find_dependency(Boost 1.65.1 COMPONENTS graph REQUIRED)
11-
find_dependency(LLVM 14 REQUIRED CONFIG)
12+
find_dependency(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG)
13+
find_dependency(LLVM ${PHASAR_LLVM_VERSION} REQUIRED CONFIG)
1214

1315
set(PHASAR_USE_LLVM_FAT_LIB @USE_LLVM_FAT_LIB@)
1416
set(PHASAR_BUILD_DYNLIB @PHASAR_BUILD_DYNLIB@)
1517
set(PHASAR_USE_Z3 @PHASAR_USE_Z3@)
18+
set(PHASAR_HAS_SQLITE @PHASAR_HAS_SQLITE@)
1619

1720
if (PHASAR_USE_Z3)
18-
find_dependency(Z3)
21+
find_dependency(Z3 REQUIRED)
22+
endif()
23+
if(PHASAR_HAS_SQLITE)
24+
find_dependency(SQLite3 REQUIRED)
1925
endif()
2026

2127
set(PHASAR_COMPONENTS
@@ -67,6 +73,8 @@ if (NOT DEFINED phasar_FOUND OR phasar_FOUND EQUAL TRUE)
6773
endif()
6874

6975
function(phasar_config executable)
76+
message(DEPRECATION "The function 'phasar_config' is deprecated. Use target_link_libraries(${executable} PUBLIC phasar::phasar) instead!")
77+
7078
target_link_libraries(${executable}
7179
PUBLIC
7280
${PHASAR_NEEDED_LIBS}

cmake/add_nlohmann_json.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ function(add_json_schema_validator)
5555
INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:${PHASAR_DEPS_INSTALL_DESTINATION}/include>
5656
)
5757

58+
# Silence warning that we do not install the PUBLIC_HEADER target property.
59+
# We can't, since it contains a relative path located from deep inside the schema validator tree
60+
set_target_properties(nlohmann_json_schema_validator PROPERTIES PUBLIC_HEADER "")
61+
5862
install(TARGETS nlohmann_json_schema_validator
5963
EXPORT ${PHASAR_DEPS_EXPORT_SET}
6064
LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib
6165
ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib
6266
RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin
67+
# PUBLIC_HEADER DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include/nlohmann
6368
)
6469
install(FILES external/json-schema-validator/src/nlohmann/json-schema.hpp
6570
DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include/nlohmann

docs/Doxyfile.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
3232
# title of most generated pages and in a few other places.
3333
# The default value is: My Project.
3434

35-
PROJECT_NAME = "Phasar"
35+
PROJECT_NAME = "PhASAR"
3636

3737
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
3838
# could be handy for archiving the generated documentation or if some version
@@ -44,7 +44,7 @@ PROJECT_NUMBER = @PHASAR_VERSION@
4444
# for a project that appears at the top of each page and should give viewer a
4545
# quick idea about the purpose of the project. Keep the description short.
4646

47-
PROJECT_BRIEF = "Phasar a LLVM-based Static Analysis Framework"
47+
PROJECT_BRIEF = "PhASAR a LLVM-based Static Analysis Framework"
4848

4949
# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
5050
# the documentation. The maximum height of the logo should not exceed 55 pixels
@@ -234,7 +234,7 @@ TCL_SUBST =
234234
# members will be omitted, etc.
235235
# The default value is: NO.
236236

237-
OPTIMIZE_OUTPUT_FOR_C = YES
237+
OPTIMIZE_OUTPUT_FOR_C = NO
238238

239239
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
240240
# Python sources only. Doxygen will then generate output that is more tailored
@@ -298,7 +298,7 @@ AUTOLINK_SUPPORT = YES
298298
# diagrams that involve STL classes more complete and accurate.
299299
# The default value is: NO.
300300

301-
BUILTIN_STL_SUPPORT = NO
301+
BUILTIN_STL_SUPPORT = YES
302302

303303
# If you use Microsoft's C++/CLI language, you should set this option to YES to
304304
# enable parsing support.
@@ -424,7 +424,7 @@ EXTRACT_STATIC = NO
424424
# for Java sources.
425425
# The default value is: YES.
426426

427-
EXTRACT_LOCAL_CLASSES = YES
427+
EXTRACT_LOCAL_CLASSES = NO
428428

429429
# This flag is only useful for Objective-C code. When set to YES local methods,
430430
# which are defined in the implementation section but not in the interface are
@@ -513,7 +513,7 @@ SHOW_GROUPED_MEMB_INC = NO
513513
# files with double quotes in the documentation rather than with sharp brackets.
514514
# The default value is: NO.
515515

516-
FORCE_LOCAL_INCLUDES = NO
516+
FORCE_LOCAL_INCLUDES = YES
517517

518518
# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
519519
# documentation for inline members.
@@ -892,7 +892,7 @@ USE_MDFILE_AS_MAINPAGE =
892892
# also VERBATIM_HEADERS is set to NO.
893893
# The default value is: NO.
894894

895-
SOURCE_BROWSER = NO
895+
SOURCE_BROWSER = YES
896896

897897
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
898898
# classes and enums directly into the documentation.
@@ -911,7 +911,7 @@ STRIP_CODE_COMMENTS = YES
911911
# function all documented functions referencing it will be listed.
912912
# The default value is: NO.
913913

914-
REFERENCED_BY_RELATION = NO
914+
REFERENCED_BY_RELATION = YES
915915

916916
# If the REFERENCES_RELATION tag is set to YES then for each documented function
917917
# all documented entities called/used by that function will be listed.

docs/README.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22

3-
@mainpage Phasar a LLVM-based Static Analysis Framework
3+
@mainpage PhASAR: A LLVM-based Static Analysis Framework
44

55
@author Philipp Schubert (E-Mail: philipp.schubert@upb.de) and others
66

examples/use-phasar-as-library/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ add_executable(myphasartool
1717
myphasartool.cpp
1818
)
1919

20-
# Old way using phasar_config:
20+
# Old way using phasar_config (deprecated):
2121
# phasar_config(myphasartool)
2222

2323
# New way using target_link_libraries:

examples/use-phasar-as-library/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ This small example shows how you can setup a CMake project that uses PhASAR as a
44
This guide assumes that you have installed PhASAR such that the `find_package` cmake command can find it.
55

66
You can choose the PhASAR components that you need in the `find_package` command.
7+
8+
To use phasar from a custom install location, you may specify the `phasar_ROOT` CMake variable to point to phasar's install directory.

examples/use-phasar-with-fetch-content/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,26 @@ include(FetchContent)
1212
FetchContent_Declare(
1313
phasar
1414
GIT_REPOSITORY https://github.com/secure-software-engineering/phasar.git
15-
GIT_TAG development
15+
GIT_TAG development # At best, use a tagged version, such as v2403
1616
EXCLUDE_FROM_ALL
1717
OVERRIDE_FIND_PACKAGE
1818
)
1919

2020
find_package(phasar REQUIRED)
2121

2222
# Build a small test tool to show how phasar may be used
23-
add_executable(myphasartool_fc
23+
add_executable(myphasartool
2424
myphasartool.cpp
2525
)
2626

27-
# Old way using phasar_config:
28-
# phasar_config(myphasartool)
29-
30-
# New way using target_link_libraries:
31-
target_link_libraries(myphasartool_fc phasar::llvm_ifdside)
27+
target_link_libraries(myphasartool phasar::llvm_ifdside)
3228

3329
# If find_package did not specify components:
3430
# target_link_libraries(myphasartool phasar::phasar)
3531
# alternatively using the default target:
3632
# target_link_libraries(myphasartool phasar)
3733

38-
install(TARGETS myphasartool_fc
34+
install(TARGETS myphasartool
3935
RUNTIME DESTINATION bin
4036
LIBRARY DESTINATION lib
4137
ARCHIVE DESTINATION lib

external/json

Submodule json updated 286 files

0 commit comments

Comments
 (0)