From 75a8d516740ac3ce75b7c1bf99df7e9856bcf81d Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Sun, 16 Feb 2025 18:09:05 +0100 Subject: [PATCH 1/6] Use file sets for headers to improve IDE integration --- CMakeLists.txt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9d6409c91..7373899b83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.14) +cmake_minimum_required (VERSION 3.14...3.28) # Avoid IPO/LTO Warnings: cmake_policy(SET CMP0069 NEW) @@ -257,9 +257,16 @@ endif() # Headers add_library(phasar_interface INTERFACE) +file(GLOB_RECURSE PHASAR_PUBLIC_HEADERS include/*.h include/*.def) +target_sources(phasar_interface INTERFACE + FILE_SET HEADERS + BASE_DIRS ${PHASAR_SRC_DIR}/include + FILES ${PHASAR_PUBLIC_HEADERS} +) + target_include_directories(phasar_interface INTERFACE - $ # The regular include folder + # Not mention ${PHASAR_SRC_DIR}/include here as it is already specified in the target_sources above! $ # The location of phasar-config.h $ # The installed include folder ) @@ -412,14 +419,6 @@ set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Install dir of lib # Install targets of phasar-cli, other executables, and libraries are to be # found in the individual subdirectories of tools/ -# Install Phasar include directory -install(DIRECTORY include/ - DESTINATION include - FILES_MATCHING - PATTERN "*.def" - PATTERN "*.h" -) - # Install the config file install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/phasar/Config/ DESTINATION include/phasar/Config @@ -431,6 +430,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/phasar/Config/ if(NOT PHASAR_IN_TREE) install(TARGETS phasar_interface EXPORT PhasarExports + FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if (NOT PHASAR_USE_CONAN) # Install the export-set containing all the phasar targets @@ -448,6 +448,7 @@ if(NOT PHASAR_IN_TREE) else() install(TARGETS phasar_interface EXPORT LLVMExports + FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS phasar_interface) endif() @@ -457,6 +458,7 @@ install(DIRECTORY utils/ DESTINATION bin FILES_MATCHING PATTERN "CodeGen" EXCLUDE # CodeGen does not contain files to install + PATTERN "conan" EXCLUDE # Don't install conan utils PATTERN "phasar-*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ From a05c3570fd80af2fc0bad23ab89430f39f874bb0 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Sun, 16 Feb 2025 18:09:27 +0100 Subject: [PATCH 2/6] bump dependencies --- .gitignore | 2 +- CMakeLists.txt | 1 + cmake/add_nlohmann_json.cmake | 5 +++++ external/json | 2 +- external/json-schema-validator | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index df7dd6a47c..f86934e8b1 100644 --- a/.gitignore +++ b/.gitignore @@ -46,7 +46,7 @@ build/* .idea/* # cache -.cache/* +.cache/ ##### ignored files diff --git a/CMakeLists.txt b/CMakeLists.txt index 7373899b83..4947ce8a9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,6 +293,7 @@ if (NOT PHASAR_IN_TREE) if(PHASAR_BUILD_UNITTESTS AND NOT TARGET gtest) include(FetchContent) + set(INSTALL_GTEST OFF) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git diff --git a/cmake/add_nlohmann_json.cmake b/cmake/add_nlohmann_json.cmake index 8cfd3f69c8..b15afc1b5e 100644 --- a/cmake/add_nlohmann_json.cmake +++ b/cmake/add_nlohmann_json.cmake @@ -55,11 +55,16 @@ function(add_json_schema_validator) INTERFACE_INCLUDE_DIRECTORIES $ ) + # Silence warning that we do not install the PUBLIC_HEADER target property. + # We can't, since it contains a relative path located from deep inside the schema validator tree + set_target_properties(nlohmann_json_schema_validator PROPERTIES PUBLIC_HEADER "") + install(TARGETS nlohmann_json_schema_validator EXPORT ${PHASAR_DEPS_EXPORT_SET} LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin + # PUBLIC_HEADER DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include/nlohmann ) install(FILES external/json-schema-validator/src/nlohmann/json-schema.hpp DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include/nlohmann diff --git a/external/json b/external/json index bc889afb4c..9cca280a4d 160000 --- a/external/json +++ b/external/json @@ -1 +1 @@ -Subproject commit bc889afb4c5bf1c0d8ee29ef35eaaf4c8bef8a5d +Subproject commit 9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03 diff --git a/external/json-schema-validator b/external/json-schema-validator index 491ac44026..349cba9f7e 160000 --- a/external/json-schema-validator +++ b/external/json-schema-validator @@ -1 +1 @@ -Subproject commit 491ac44026e08f31790f5cacffa62e168bb35e32 +Subproject commit 349cba9f7e3cb423bbc1811bdd9f6770f520b468 From c978fb8525017c4eba1f184df5e9da4738517f34 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Sat, 22 Feb 2025 15:53:57 +0100 Subject: [PATCH 3/6] Deprecate PHASAR_EXPERIMENTAL_CXX20 + modernize boost finding via find_package(CONFIG) --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dbc23a43f..8b6d8af764 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,10 @@ else() endif() option(PHASAR_EXPERIMENTAL_CXX20 "Build phasar in C++20 mode. This is an experimental feature" OFF) +if(PHASAR_EXPERIMENTAL_CXX20) + 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.") + set(CMAKE_CXX_STANDARD 20) +endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -279,7 +283,7 @@ target_include_directories(phasar_interface find_package(Threads) # Boost -find_package(Boost 1.65.1 COMPONENTS graph REQUIRED) +find_package(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG) # Disable clang-tidy for the external projects set(CMAKE_CXX_CLANG_TIDY "") From 6e819f93eea4265254b94aa6a33047b59f058d17 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Sat, 22 Feb 2025 16:18:01 +0100 Subject: [PATCH 4/6] update gtest version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b6d8af764..4d8780acb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,7 +303,7 @@ if (NOT PHASAR_IN_TREE) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG v1.13.0 + GIT_TAG v1.16.0 ) FetchContent_MakeAvailable(googletest) endif() From 5d617ee376c5c33359cd2764702b699c5e01de3a Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Sun, 23 Feb 2025 11:28:54 +0100 Subject: [PATCH 5/6] Somplify headers inclusion + fix boost include for installed phasar --- CMakeLists.txt | 43 +++++++++++++------------------------------ Config.cmake.in | 2 +- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d8780acb6..b1f7229fc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,24 +259,6 @@ else() set(PHASAR_CONFIG_INSTALL_DIR "${PHASAR_CUSTOM_CONFIG_INSTALL_DIR}") endif() - -# Headers - -add_library(phasar_interface INTERFACE) -file(GLOB_RECURSE PHASAR_PUBLIC_HEADERS include/*.h include/*.def) -target_sources(phasar_interface INTERFACE - FILE_SET HEADERS - BASE_DIRS ${PHASAR_SRC_DIR}/include - FILES ${PHASAR_PUBLIC_HEADERS} -) - -target_include_directories(phasar_interface - INTERFACE - # Not mention ${PHASAR_SRC_DIR}/include here as it is already specified in the target_sources above! - $ # The location of phasar-config.h - $ # The installed include folder -) - ### Adding external libraries # Threads @@ -369,9 +351,6 @@ if(NOT PHASAR_IN_TREE) add_definitions(${LLVM_DEFINITIONS_LIST}) endif() -# Installed config -configure_file(config.h.in include/phasar/Config/phasar-config.h @ONLY) - # Warnings option(PHASAR_ENABLE_WARNINGS "Enable warnings" ${PHASAR_BUILD_OPTIONAL_TARGETS_DEFAULT}) if (PHASAR_ENABLE_WARNINGS) @@ -382,6 +361,18 @@ if (PHASAR_ENABLE_WARNINGS) endif() endif (PHASAR_ENABLE_WARNINGS) + +# Headers +add_library(phasar_interface INTERFACE) +file(GLOB_RECURSE PHASAR_PUBLIC_HEADERS include/*.h include/*.def) +configure_file(config.h.in include/phasar/Config/phasar-config.h @ONLY) + +target_sources(phasar_interface INTERFACE + FILE_SET HEADERS + BASE_DIRS "${PHASAR_SRC_DIR}/include" "${PHASAR_BINARY_DIR}/include" + FILES ${PHASAR_PUBLIC_HEADERS} "${PHASAR_BINARY_DIR}/include/phasar/Config/phasar-config.h" +) + # Some preprocessor symbols that need to be available in phasar sources, but should not be installed add_cxx_compile_definitions(PHASAR_SRC_DIR="${CMAKE_SOURCE_DIR}") add_cxx_compile_definitions(PHASAR_BUILD_DIR="${CMAKE_BINARY_DIR}") @@ -426,14 +417,6 @@ set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Install dir of lib # Install targets of phasar-cli, other executables, and libraries are to be # found in the individual subdirectories of tools/ -# Install the config file -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/phasar/Config/ - DESTINATION include/phasar/Config - FILES_MATCHING - PATTERN "*.def" - PATTERN "*.h" -) - if(NOT PHASAR_IN_TREE) install(TARGETS phasar_interface EXPORT PhasarExports @@ -448,7 +431,7 @@ if(NOT PHASAR_IN_TREE) ) install(EXPORT ${PHASAR_DEPS_EXPORT_SET} FILE ${PHASAR_DEPS_EXPORT_SET}.cmake - NAMESPACE phasar:: + NAMESPACE phasar::deps:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/phasar" ) endif() diff --git a/Config.cmake.in b/Config.cmake.in index adc1a9a6ca..dd9d2f154d 100644 --- a/Config.cmake.in +++ b/Config.cmake.in @@ -7,7 +7,7 @@ set_and_check(PHASAR_LIBRARY_DIR "@PACKAGE_LIBRARY_INSTALL_DIR@") include (CMakeFindDependencyMacro) include("${CMAKE_CURRENT_LIST_DIR}/PhasarDepsExports.cmake") -find_dependency(Boost 1.65.1 COMPONENTS graph REQUIRED) +find_dependency(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG) find_dependency(LLVM 14 REQUIRED CONFIG) set(PHASAR_USE_LLVM_FAT_LIB @USE_LLVM_FAT_LIB@) From 98b82527a41cb6e9b81f363ca6dff8d2430a20d0 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Sat, 1 Mar 2025 19:21:04 +0100 Subject: [PATCH 6/6] Revisit examples and docs --- Config.cmake.in | 12 ++++++++++-- docs/Doxyfile.in | 18 +++++++++--------- docs/README.dox | 2 +- examples/use-phasar-as-library/CMakeLists.txt | 2 +- examples/use-phasar-as-library/README.md | 2 ++ .../CMakeLists.txt | 12 ++++-------- lib/LibPhasar.cpp | 3 +++ 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Config.cmake.in b/Config.cmake.in index dd9d2f154d..ee40b7d2ee 100644 --- a/Config.cmake.in +++ b/Config.cmake.in @@ -6,16 +6,22 @@ set_and_check(PHASAR_LIBRARY_DIR "@PACKAGE_LIBRARY_INSTALL_DIR@") include (CMakeFindDependencyMacro) +set(PHASAR_LLVM_VERSION @PHASAR_LLVM_VERSION@) + include("${CMAKE_CURRENT_LIST_DIR}/PhasarDepsExports.cmake") find_dependency(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG) -find_dependency(LLVM 14 REQUIRED CONFIG) +find_dependency(LLVM ${PHASAR_LLVM_VERSION} REQUIRED CONFIG) set(PHASAR_USE_LLVM_FAT_LIB @USE_LLVM_FAT_LIB@) set(PHASAR_BUILD_DYNLIB @PHASAR_BUILD_DYNLIB@) set(PHASAR_USE_Z3 @PHASAR_USE_Z3@) +set(PHASAR_HAS_SQLITE @PHASAR_HAS_SQLITE@) if (PHASAR_USE_Z3) - find_dependency(Z3) + find_dependency(Z3 REQUIRED) +endif() +if(PHASAR_HAS_SQLITE) + find_dependency(SQLite3 REQUIRED) endif() set(PHASAR_COMPONENTS @@ -67,6 +73,8 @@ if (NOT DEFINED phasar_FOUND OR phasar_FOUND EQUAL TRUE) endif() function(phasar_config executable) + message(DEPRECATION "The function 'phasar_config' is deprecated. Use target_link_libraries(${executable} PUBLIC phasar::phasar) instead!") + target_link_libraries(${executable} PUBLIC ${PHASAR_NEEDED_LIBS} diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index dbf9245f07..093c9c9477 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "Phasar" +PROJECT_NAME = "PhASAR" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.1 +PROJECT_NUMBER = 2403 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = "Phasar a LLVM-based Static Analysis Framework" +PROJECT_BRIEF = "PhASAR a LLVM-based Static Analysis Framework" # With the PROJECT_LOGO tag one can specify an logo or icon that is included in # the documentation. The maximum height of the logo should not exceed 55 pixels @@ -234,7 +234,7 @@ TCL_SUBST = # members will be omitted, etc. # The default value is: NO. -OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored @@ -298,7 +298,7 @@ AUTOLINK_SUPPORT = YES # diagrams that involve STL classes more complete and accurate. # The default value is: NO. -BUILTIN_STL_SUPPORT = NO +BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. @@ -424,7 +424,7 @@ EXTRACT_STATIC = NO # for Java sources. # The default value is: YES. -EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local methods, # which are defined in the implementation section but not in the interface are @@ -513,7 +513,7 @@ SHOW_GROUPED_MEMB_INC = NO # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. -FORCE_LOCAL_INCLUDES = NO +FORCE_LOCAL_INCLUDES = YES # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. @@ -892,7 +892,7 @@ USE_MDFILE_AS_MAINPAGE = # also VERBATIM_HEADERS is set to NO. # The default value is: NO. -SOURCE_BROWSER = NO +SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. @@ -911,7 +911,7 @@ STRIP_CODE_COMMENTS = YES # function all documented functions referencing it will be listed. # The default value is: NO. -REFERENCED_BY_RELATION = NO +REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. diff --git a/docs/README.dox b/docs/README.dox index 3113dfdaed..e00ef59771 100644 --- a/docs/README.dox +++ b/docs/README.dox @@ -1,6 +1,6 @@ /** -@mainpage Phasar a LLVM-based Static Analysis Framework +@mainpage PhASAR: A LLVM-based Static Analysis Framework @author Philipp Schubert (E-Mail: philipp.schubert@upb.de) and others diff --git a/examples/use-phasar-as-library/CMakeLists.txt b/examples/use-phasar-as-library/CMakeLists.txt index a7bfaa8d96..5246e3b823 100644 --- a/examples/use-phasar-as-library/CMakeLists.txt +++ b/examples/use-phasar-as-library/CMakeLists.txt @@ -17,7 +17,7 @@ add_executable(myphasartool myphasartool.cpp ) -# Old way using phasar_config: +# Old way using phasar_config (deprecated): # phasar_config(myphasartool) # New way using target_link_libraries: diff --git a/examples/use-phasar-as-library/README.md b/examples/use-phasar-as-library/README.md index 44dbce6ea8..5f5f6c1828 100644 --- a/examples/use-phasar-as-library/README.md +++ b/examples/use-phasar-as-library/README.md @@ -4,3 +4,5 @@ This small example shows how you can setup a CMake project that uses PhASAR as a This guide assumes that you have installed PhASAR such that the `find_package` cmake command can find it. You can choose the PhASAR components that you need in the `find_package` command. + +To use phasar from a custom install location, you may specify the `phasar_ROOT` CMake variable to point to phasar's install directory. diff --git a/examples/use-phasar-with-fetch-content/CMakeLists.txt b/examples/use-phasar-with-fetch-content/CMakeLists.txt index 15033beade..cd4d5bb5f2 100644 --- a/examples/use-phasar-with-fetch-content/CMakeLists.txt +++ b/examples/use-phasar-with-fetch-content/CMakeLists.txt @@ -12,7 +12,7 @@ include(FetchContent) FetchContent_Declare( phasar GIT_REPOSITORY https://github.com/secure-software-engineering/phasar.git - GIT_TAG development + GIT_TAG development # At best, use a tagged version, such as v2403 EXCLUDE_FROM_ALL OVERRIDE_FIND_PACKAGE ) @@ -20,22 +20,18 @@ FetchContent_Declare( find_package(phasar REQUIRED) # Build a small test tool to show how phasar may be used -add_executable(myphasartool_fc +add_executable(myphasartool myphasartool.cpp ) -# Old way using phasar_config: -# phasar_config(myphasartool) - -# New way using target_link_libraries: -target_link_libraries(myphasartool_fc phasar::llvm_ifdside) +target_link_libraries(myphasartool phasar::llvm_ifdside) # If find_package did not specify components: # target_link_libraries(myphasartool phasar::phasar) # alternatively using the default target: # target_link_libraries(myphasartool phasar) -install(TARGETS myphasartool_fc +install(TARGETS myphasartool RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib diff --git a/lib/LibPhasar.cpp b/lib/LibPhasar.cpp index 97bbc811c2..7c72ce7695 100644 --- a/lib/LibPhasar.cpp +++ b/lib/LibPhasar.cpp @@ -8,3 +8,6 @@ *****************************************************************************/ #include "phasar.h" + +/// PhASAR's main namespace. All phasar-APIs are found here +namespace psr {}