Answer the question
In order to leave comments, you need to log in
Is it possible through CMake to build a project that is going to be built with a bash script?
I'm trying to add a specific version of openssl to my CMake tree.
I know that it is possible to execute commands in the shell via execute_command which works at configuration time and with add_custom_command which works at build time. Unfortunately, in the second option, you either need to specify a target or an output file - I don’t have a target, what OUTPUT is, I didn’t fully understand.
If someone has experience with adding non-CMake projects to CMake, please share.
Answer the question
In order to leave comments, you need to log in
add_custom_command is useful when you have some of your sources generated by some other program (eg flex, protobuf). In this case, OUTPUT will point to the generated files using the COMMAND command. You can see my answer on the topic .
The easiest way (but not always the best) to build a third party non-CMake project is to use ExternalProject_Add . Difficulties arise when you need to add this project as a dependency to your own. The most obvious way is to use find_package with the correct paths. For example for OpenSSL:
...
# Вместо этой строчки также можно указать путь из командой строки:
# $ cmake -DOPENSSL_ROOT_DIR=/usr/local/ssl -DOPENSSL_LIBRARIES=/usr/local/ssl/lib ..
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/openssl)
# Используем FindOpenSSL.cmake для поиска
find_package(OpenSSL REQUIRED)
...
target_link_directories(my_target ${CMAKE_CURRENT_SOURCE_DIR}/openssl/lib)
target_link_libraries(my_target PRIVATE crypto ssl)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question