I have the following CMakeLists.txt
:
macro (set_echo NAME VALUE) set (${NAME} "${VALUE}") message (STATUS "${NAME} : \"${VALUE}\"")endmacro ()set_echo ( CURRENT_VERSION 1.2.3)string (REPLACE "." "" VERSION_NO_DOT ${CURRENT_VERSION})message (STATUS "VERSION_NO_DOT : \"${VERSION_NO_DOT}\"")execute_process("/bin/bash -c 'export VERSION_NO_DOT=\"${VERSION_NO_DOT}\"'")
Now I want to export the VERSION_NO_DOT
in CMake:
# cmake . (??? how to just export instead of building the project ???)
Here is the error:
-- The CXX compiler identification is GNU 11.4.0-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Check for working C compiler: /usr/bin/cc - skipped-- Detecting C compile features-- Detecting C compile features - done-- Detecting CXX compiler ABI info-- Detecting CXX compiler ABI info - done-- Check for working CXX compiler: /usr/bin/c++ - skipped-- Detecting CXX compile features-- Detecting CXX compile features - done-- CURRENT_VERSION : "1.2.3"-- VERSION_NO_DOT : "123"CMake Error at CMakeLists.txt:15 (execute_process): execute_process given unknown argument "/bin/bash -c 'export VERSION_NO_DOT="123"'".CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 3.29) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000".This warning is for project developers. Use -Wno-dev to suppress it.-- Configuring incomplete, errors occurred!
And then, I want to get the VERSION_NO_DOT
in bash:
# echo "VERSION_NO_DOT in bash is: $VERSION_NO_DOT"
Here is the expected output:
VERSION_NO_DOT in bash is: 123
Is this possible in CMake
? How to do this?