Created
December 25, 2024 06:19
-
-
Save chenrui333/5bf0eb8b6e00c13d071b96cb9aeafcc8 to your computer and use it in GitHub Desktop.
libformfactor formula pr, https://github.com/Homebrew/homebrew-core/pull/202225
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index dbae506..79a0220 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -51,9 +51,19 @@ endif() | |
## Dependences. | |
-find_package(LibHeinz REQUIRED) | |
-message(STATUS "LibHeinz: found=${LibHeinz_FOUND}, include_dirs=${LibHeinz_INCLUDE_DIR}, " | |
- "version=${LibHeinz_VERSION}") | |
+find_package(LibHeinz CONFIG REQUIRED HINTS | |
+ "${CMAKE_INSTALL_PREFIX}/lib/cmake/libheinz" | |
+ "/usr/local/lib/cmake/libheinz" | |
+ "/opt/homebrew/lib/cmake/libheinz" | |
+ ENV CMAKE_PREFIX_PATH | |
+) | |
+ | |
+if (LibHeinz_FOUND) | |
+ message(STATUS "LibHeinz include directory: ${LibHeinz_INCLUDE_DIR}") | |
+ message(STATUS "LibHeinz version: ${LibHeinz_VERSION}") | |
+else() | |
+ message(FATAL_ERROR "LibHeinz not found in ${CMAKE_PREFIX_PATH}") | |
+endif() | |
## Source directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index 0eca7a1..7318860 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -4,22 +4,18 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | |
include(PreventInSourceBuilds) | |
project(LibHeinz VERSION 2.0.0 LANGUAGES CXX) | |
+set(PROJECT_NAMESPACE LibHeinz) | |
-## Options. | |
- | |
-if(NOT DEFINED BUILD_SHARED_LIBS) | |
- option(BUILD_SHARED_LIBS "Build as shared library" ON) | |
-endif() | |
+## Options | |
+option(BUILD_SHARED_LIBS "Build as shared library" ON) | |
option(PEDANTIC "Compile with pedantic warnings" ON) | |
option(WERROR "Treat warnings as errors" OFF) | |
-## Compiler settings. | |
- | |
+## Compiler settings | |
set(CMAKE_CXX_STANDARD 17) | |
add_compile_options(-O2) | |
if(WIN32) | |
set(WINDOWS_EXPORT_ALL_SYMBOLS ON) | |
- message(STATUS "compiling for Windows") | |
else() | |
add_compile_options(-Wall -Wno-unknown-pragmas) | |
if(PEDANTIC) | |
@@ -30,15 +26,12 @@ if(WERROR) | |
add_compile_options(-Werror) | |
endif() | |
-## Subdirectories. | |
- | |
+## Subdirectories | |
include(CTest) | |
- | |
add_subdirectory(inc) | |
add_subdirectory(test) | |
-## CPack settings. | |
- | |
+## CPack settings | |
include(InstallRequiredSystemLibraries) | |
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") | |
set(CPACK_PACKAGE_VERSION_MAJOR "${LibHeinz_VERSION_MAJOR}") | |
@@ -46,24 +39,23 @@ set(CPACK_PACKAGE_VERSION_MINOR "${LibHeinz_VERSION_MINOR}") | |
set(CPACK_SOURCE_GENERATOR "TGZ") | |
include(CPack) | |
include(CMakePackageConfigHelpers) | |
-export(PACKAGE LibHeinz) | |
- | |
-## Config files. | |
+export(PACKAGE ${PROJECT_NAME}) | |
+## Config files | |
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in" | |
- "${CMAKE_CURRENT_BINARY_DIR}/LibHeinzConfig.cmake" | |
- INSTALL_DESTINATION "lib/cmake/example" | |
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | |
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | |
NO_SET_AND_CHECK_MACRO | |
NO_CHECK_REQUIRED_COMPONENTS_MACRO | |
) | |
write_basic_package_version_file( | |
- "${CMAKE_CURRENT_BINARY_DIR}/LibHeinzConfigVersion.cmake" | |
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" | |
VERSION "${LibHeinz_VERSION}" | |
COMPATIBILITY AnyNewerVersion | |
) | |
install(FILES | |
- "${PROJECT_BINARY_DIR}/LibHeinzConfig.cmake" | |
- "${PROJECT_BINARY_DIR}/LibHeinzConfigVersion.cmake" | |
- DESTINATION cmake COMPONENT dev) | |
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | |
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" | |
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment