[build] fix when openssl is static build fail #3097
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In actual usage, I experienced a problem where I
set(OpenSSL_DIR /path/lib/cmake/OpenSSL)
and then integrated the SRT project into my own by usingadd_subdirectory
. The first CMake configuration would succeed, but the second configuration attempt would fail.The details are as follows:
It seems to be ok, but when I do the first cmake config, and the second cmake config with caching, I get different results.
In the above message, OPENSSL_INCLUDE_DIR has a value the first time, and is empty the second time.
After cmake config and troubleshooting again and again, I finally found that: CMakeLists.txt#L175-OPENSSL_USE_STATIC_LIBS will cause cmake config to fail.
The reason is that there will be the same variables in
OpenSSLConfig.cmake
.Because there is no cache when cmake config is run for the first time, it works fine, but the second time, there is a cache, which causes failure.
We should not define the same variables as those in config.cmake generated by make install, we should name them differently.