logo
down
shadow

cmake configure_file does not expand mylib.pc.in correctly


cmake configure_file does not expand mylib.pc.in correctly

Content Index :

cmake configure_file does not expand mylib.pc.in correctly
Tag : cmake , By : Marianisho
Date : January 11 2021, 05:14 PM

help you fix your problem Construction ${prefix} is a variable reference both in CMake scripting and in .pc file scripting. So you need to choose at which stage you want to expand this reference:
# File: CMakeLists.txt
set(prefix "$ENV{HOME}/xcompiled-root/")
configure_file(mylib.pc.in mylib.pc)
# File: mylib.pc.in
exe_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
exe_prefix=/home/myusr/xcompiled-root/
libdir=/home/myusr/xcompiled-root/lib
includedir=/home/myusr/xcompiled-root/include
# File: mylib.pc.in
prefix=$ENV{HOME}/xcompiled-root/
exe_prefix=$${}{prefix}
libdir=$${}{prefix}/lib
includedir=$${}{prefix}/include
# File: CMakeLists.txt
configure_file(mylib.pc.in mylib.pc)
prefix=/home/myusr/xcompiled-root/
exe_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
# File: CMakeLists.txt
# Construction @VAR@ doesn't support reference to environment variable.
# So prepare pure CMake variable which contains $ENV{HOME}.
set(user_home "$ENV{HOME}")
configure_file(mylib.pc.in mylib.pc @ONLY)
prefix=@user_home@/xcompiled-root/
exe_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires:
Libs: -L@{libdir} -lpthread -lrt -ldl  -lm
Cflags: -I@{includedir}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

CMake configure_file replace ON/OFF with 1/0


Tag : cmake , By : Longchao Dong
Date : March 29 2020, 07:55 AM
will help you Suppose I have two libraries ABC, XYZ and two variables ABC_FOUND XYZ_FOUND in CMakeLists.txt. In a config.h.in file, I have the following lines , Define ABC_FOUND to either 0 or 1 with
#cmakedefine01 @ABC_FOUND@

CMake and configure_file: what if I need $ONLY instead of @ONLY?


Tag : cmake , By : Pierre LeBoo
Date : March 29 2020, 07:55 AM
it fixes the issue At least I found a solution that works, even if I'm not sure that's the best approach ever.
I leave it as an answer for future readers in case no solutions come up.
@DontTouchMe@/${PROJECT_NAME}
@@Workaround@DontTouchMe@Workaround@@/${PROJECT_NAME}
@DontTouchMe@/TheNameOfTheProject

CMake Error (configure_file): configure_file error configuring file


Tag : cmake , By : mansoor
Date : March 29 2020, 07:55 AM
around this issue I am working on a project on c++ and need to execute a CMakeLists.txt file to run it. I installed cmake, doxygen, cmake-curses-gui and make using sudo. Then I tried running the file. , The error is clear
configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.in ${PROJECT_SOURCE_DIR}/doc/Doxyfile @ONLY)

CMake : different configure_file() for each target


Tag : c , By : kbrust
Date : March 29 2020, 07:55 AM
To fix the issue you can do The command configure_file creates a "real" file: it has the same content for each target.
However, the created file may contain #ifdef (or other conditional statements), so its interpretation may differ for different target.
#ifndef TEST
#define MY_A 10    
#endif
#ifdef PINK
#define MY_A 20
#endif
add_executable(FirstTarget ...)
# When "config.h" will be included into this target, it will use "PINK" branch.
target_compile_definitions(FirstTarget PRIVATE PINK)

add_executable(SecondTarget ...)
# When "config.h" will be included into this target, it will use "TEST" branch.
target_compile_definitions(FirstTarget PRIVATE TEST)

CMake: Is it possible to run CONFIGURE_FILE after each make?


Tag : makefile , By : lwl_seu
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to link to <math.h> library using CMake?
  • Building Boost as an ExternalProject_Add and either FindBoost or export the results
  • Should I cache CMAKE_BUILD_TYPE?
  • What does CMAKE_BUILD_TYPE affect, other than the compiler flag selection?
  • Why does CMake EXPORT require static libraries used to build a shared library?
  • CMake/Ninja: Recursive "cleaning" of output directories when contents are unknown...?
  • How to build eclipse paho with cmake
  • How can I generate a GUID in CMake?
  • cmake: install header order and dependencies on target
  • CMake, multiple targets (asan tsan..) without having to recompile everything
  • Using cmake options in generator expressions
  • Licensing: What is the license for LibFindMacros.cmake
  • CMake - How does the if() command treat a symbol? As string or as variable?
  • Automatically add linking options to dependants of shared lib
  • CMake Error: include could not find load file: targets
  • How to get cmake generate -std=c++14 flag for qcc compiler
  • Check for compatibility
  • Return in CMake macro ends upper CMake file execution?
  • CMake find_dependency does not respect the behaviour in the package documentation?
  • How to pass combined compiler options with target_compile_options in CMake?
  • What is the use case for generator expression on target_include_directories?
  • CONAN_PKG::<PKG-NAME> not found when using cmake to generate build target
  • CMake Custom Command Depending On Variable
  • Difference between FooTarget.cmake and FindFoo.cmake?
  • What's the difference between find_package(MPI) and FindMPI?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com