1
- function (find_botan_pkgconfig package_name botan_ver )
2
- if (TARGET Botan::Botan )
1
+ function (find_botan_pkgconfig package_name )
2
+ if (TARGET Botan::Botan )
3
3
return ()
4
- endif ()
4
+ endif ()
5
5
6
- pkg_check_modules (Botan QUIET IMPORTED_TARGET ${package_name} )
7
- if (TARGET PkgConfig::Botan )
6
+ pkg_check_modules (
7
+ Botan
8
+ QUIET
9
+ IMPORTED_TARGET
10
+ GLOBAL
11
+ ${package_name}
12
+ )
13
+ if (TARGET PkgConfig::Botan )
8
14
add_library (Botan::Botan ALIAS PkgConfig::Botan )
9
15
10
- if (botan_ver EQUAL 3 )
16
+ if (${Botan_FIND_VERSION} EQUAL 3 )
11
17
target_compile_features (PkgConfig::Botan INTERFACE cxx_std_20 )
12
18
endif ()
13
- endif ()
19
+ endif ()
14
20
endfunction ()
15
21
16
- function (find_botan_search package_name botan_ver )
17
- if (TARGET Botan::Botan )
18
- return ()
19
- endif ()
20
- find_path (Botan_INCLUDE_DIRS NAMES botan/botan.h
21
- PATH_SUFFIXES ${package_name}
22
- DOC "The Botan include directory" )
23
-
24
- find_library (Botan_LIBRARIES NAMES botan ${package_name}
25
- DOC "The Botan library" )
22
+ function (find_botan_search package_name )
23
+ # botan2 have botan.h, but botan3 does not, botan3 using auto_rng.h instead
24
+ find_path (
25
+ Botan_INCLUDE_DIRS
26
+ NAMES botan/botan.h botan/auto_rng.h
27
+ HINTS ${BOTAN_ROOT_DIR} /include
28
+ PATH_SUFFIXES ${package_name}
29
+ DOC "The Botan include directory"
30
+ )
26
31
27
- mark_as_advanced (Botan_INCLUDE_DIRS Botan_LIBRARIES )
32
+ find_library (
33
+ Botan_LIBRARIES
34
+ NAMES botan ${package_name}
35
+ HINTS ${BOTAN_ROOT_DIR} /lib
36
+ DOC "The Botan library"
37
+ )
28
38
29
39
add_library (Botan::Botan IMPORTED UNKNOWN )
30
40
set_target_properties (
@@ -33,29 +43,32 @@ function(find_botan_search package_name botan_ver)
33
43
IMPORTED_LOCATION "${Botan_LIBRARIES} "
34
44
INTERFACE_INCLUDE_DIRECTORIES "${Botan_INCLUDE_DIRS} "
35
45
)
36
- if (botan_ver EQUAL 3 )
46
+ if (${Botan_FIND_VERSION} EQUAL 3 )
37
47
target_compile_features (Botan::Botan INTERFACE cxx_std_20 )
38
48
endif ()
39
49
40
- if (WIN32 )
50
+ if (WIN32 )
41
51
target_compile_definitions (Botan::Botan INTERFACE -DNOMINMAX=1 )
42
- endif ()
52
+ endif ()
43
53
endfunction ()
44
54
55
+ # ######################################################################################################################
56
+ # Using find_package with verion: find_package(Botan 3) or find_package(Botan 2)
57
+ if (NOT DEFINED Botan_FIND_VERSION )
58
+ message (FATAL_ERROR "Must specify Botan version: find_package(Botan 3) or find_package(Botan 2)" )
59
+ endif ()
45
60
46
- find_package (PkgConfig )
47
- if (NOT WIN32 AND PKG_CONFIG_FOUND )
48
- # find_botan_pkgconfig(botan-2 2)
49
- find_botan_pkgconfig (botan-3 3 )
61
+ if (NOT WIN32 )
62
+ find_package (PkgConfig )
63
+ if (PKG_CONFIG_FOUND )
64
+ find_botan_pkgconfig (botan-${Botan_FIND_VERSION} )
65
+ endif ()
50
66
endif ()
51
67
52
68
if (NOT TARGET Botan::Botan )
53
- # find_botan_search(botan-2 2)
54
- find_botan_search (botan-3 3 )
69
+ find_botan_search (botan-${Botan_FIND_VERSION} )
55
70
endif ()
56
71
57
72
include (FindPackageHandleStandardArgs )
58
- find_package_handle_standard_args (
59
- Botan
60
- REQUIRED_VARS Botan_LIBRARIES Botan_INCLUDE_DIRS
61
- )
73
+ find_package_handle_standard_args (Botan REQUIRED_VARS Botan_LIBRARIES Botan_INCLUDE_DIRS )
74
+ mark_as_advanced (Botan_INCLUDE_DIRS Botan_LIBRARIES )
0 commit comments