Hi,
my issue is quite simple, it generates the buildsystem for a custom library and an executable.
cmake_minimum_required(VERSION 4.0)
project(my_library LANGUAGES C VERSION 0.0.1)
include(cmake/ResolveDependencies.cmake)
# cache variables for installation destinations
include(GNUInstallDirs)
# include the package config helpers and generate the file below
include(CMakePackageConfigHelpers)
add_subdirectory(libraries)
add_subdirectory(application)
It builds and installs without problems, using this batch and the specified –prefix:
@echo off
if not “%\~1”==“” (
set BUILD_TYPE=%\~1
) else (
set BUILD_TYPE=Debug
)
set DS=-DCMAKE_BUILD_TYPE=%BUILD_TYPE%
set DS=%DS% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
cmake -S . -B \_build/%BUILD_TYPE% %DS%
cmake --build \_build/%BUILD_TYPE% --parallel 4 --config %BUILD_TYPE%
cmake --install \_build/%BUILD_TYPE% --config %BUILD_TYPE% --prefix \_install/%BUILD_TYPE%
I decided to use an external library (json-c), so I added it as a git submodule and I configured the CMake to use it:
add_subdirectory(submodules/json-c_cmake/json-c)
And now, the above batch fails, telling this:
CMake Error at _build/Debug/submodules/json-c_cmake/json-c/cmake_install.cmake:125 (file):
file cannot create directory: C:/Program Files (x86)/my_library/include/json-c.
Maybe need administrative privileges.
Call Stack (most recent call first):
_build/Debug/cmake_install.cmake:37 (include)
The final CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 4.0)
project(my_library LANGUAGES C VERSION 0.0.1)
include(cmake/ResolveDependencies.cmake)
# cache variables for installation destinations
include(GNUInstallDirs)
# include the package config helpers and generate the file below
include(CMakePackageConfigHelpers)
add_subdirectory(submodules/json-c_cmake/json-c)
add_subdirectory(libraries)
add_subdirectory(application)
Is it a way, to tell this submodule, that use please the already defined –prefix?
Or, is something what I did wrong?
Best regards,
László