I attempted to compile LibreSSL using CMake for my self. LibreSSL serves as a drop-in replacement for OpenSSL, thus it may conflicts with the original OpenSSL. My intention is to use LibreSSL exclusively for my own programs, without affecting other software. AFAIK, libressl in Arch Linux packages uses --program-prefix
to specify a prefix for LibreSSL to prevent name collisions, but it is a option in autotools. I am wondering to know if there is a similiar mechanism within CMake?
See CMAKE_INSTALL_PREFIX
Sorry, perhaps I didn’t make it clear and you midunderstood it.
I mean I want the library (.so .dll etc) and program (.exe etc) start with a prefix, not specify an install directory.
e.g. I configured libressl with the following command.
../libressl-3.9.2/configure --program-prefix=libressl-
I will get libressl-openssl
libressl-ocspcheck
instead of openssl
ocspcheck
.
Sorry again for my mistake.
try something along the lines of
set_target_properties( target
PROPERTIES
PREFIX "prefix" )
For my own solution:
# inject.cmake
string(TOLOWER "${PROJECT_NAME}" LIB_PREFIX)
set(LIB_PREFIX "${LIB_PREFIX}-")
set(CMAKE_SHARED_LIBRARY_PREFIX "${LIB_PREFIX}")
# Other codes uses LIB_PREFIX
And then apply -DCMAKE_PROJECT_INCLUDE="${srcdir}/inject.cmake"
to cmake command.
It’s strange that I can’t just use -DCMAKE_SHARED_LIBRARY_PREFIX
directly.
Thanks for the inspiration.