Skip to content

Commit ad8e3b8

Browse files
committed
Add initial static Tidy library search functionality
1 parent 9e9a8be commit ad8e3b8

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

cmake/cmake/modules/FindTidy.cmake

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ The following cache variables may also be set:
3030
* `Tidy_INCLUDE_DIR` - Directory containing package library headers.
3131
* `Tidy_LIBRARY` - The path to the package library.
3232
33+
## Hints
34+
35+
This module accepts the following variables before calling `find_package(Tidy)`:
36+
37+
* `Tidy_USE_STATIC_LIBS` - Set this variable to boolean true to search for
38+
static libraries.
39+
3340
## Examples
3441
3542
Basic usage:
@@ -58,12 +65,24 @@ if(PkgConfig_FOUND)
5865
pkg_check_modules(PC_Tidy QUIET tidy)
5966
endif()
6067

68+
if(Tidy_USE_STATIC_LIBS)
69+
set(
70+
_Tidy_NAMES
71+
tidys # Some Unix-like systems.
72+
tidy_a # Windows.
73+
)
74+
else()
75+
set(
76+
_Tidy_NAMES
77+
tidy
78+
tidy5 # tidy-html5 on FreeBSD
79+
tidyp # Tidy library fork (obsolete)
80+
)
81+
endif()
82+
6183
find_library(
6284
Tidy_LIBRARY
63-
NAMES
64-
tidy
65-
tidy5 # tidy-html5 on FreeBSD
66-
tidyp # Tidy library fork (obsolete)
85+
NAMES ${_Tidy_NAMES}
6786
NAMES_PER_DIR
6887
HINTS ${PC_Tidy_LIBRARY_DIRS}
6988
DOC "The path to the Tidy library"
@@ -113,6 +132,7 @@ find_package_handle_standard_args(
113132
)
114133

115134
unset(_reason)
135+
unset(_Tidy_NAMES)
116136

117137
if(NOT Tidy_FOUND)
118138
return()
@@ -127,4 +147,12 @@ if(NOT TARGET Tidy::Tidy)
127147
IMPORTED_LOCATION "${Tidy_LIBRARY}"
128148
INTERFACE_INCLUDE_DIRECTORIES "${Tidy_INCLUDE_DIR}"
129149
)
150+
151+
if(Tidy_USE_STATIC_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "Windows")
152+
set_target_properties(
153+
Tidy::Tidy
154+
PROPERTIES
155+
INTERFACE_COMPILE_DEFINITIONS "TIDY_STATIC"
156+
)
157+
endif()
130158
endif()

0 commit comments

Comments
 (0)