.lst file generation in cmake - cmake

I want to generate .lst files for my source file. I am successfully able to generate the executable.
But I don't know how to generate .lst files for my source files.
get_property(allsrcfiles TARGET myExe PROPERTY SOURCES)
foreach(srcfile IN LISTS allsrcfiles)
set_source_files_properties(${srcfile} PROPERTIES COMPILE_FLAGS "-Wa, anhlmsd=${srcfile}.lst")
endforeach()
I have added the above script in my CMakelists.txt, if I add the above script I am getting the following error
[100%] Linking C executable myExe
dld: error: Can't open file 'CMakeFiles/myExe.dir/src/sample.c.obj': No such file or directory
CMakeFiles\myExe.dir\build.make:101: recipe for target 'myExe' failed gmake[2]: *** [myExe] Error 1
CMakeFiles\Makefile2:93: recipe for target 'CMakeFiles/myExe.dir/all' failed
gmake[1]: *** [CMakeFiles/myExe.dir/all] Error 2
Makefile:101: recipe for target 'all' failed
gmake: *** [all] Error 2
sample.c.obj file is getting generated without source_file_properties.
compiler : WIND RIVER
Target : ppc - embedded
Host : windows
is list file generation commands depends on the compiler?

Related

Dependency for add_jar cmake

I am actually generating java source files dynamically through code generators. I want to create jar file containing the java files created through this code generator.
add_custom_target(lang ALL)
add_custom_command(
TARGET lang
COMMAND ${Protobuf_PROTOC_EXECUTABLE} ${CMD_PRG_LNG} --proto_path=${PROTO_FILES} ${COMMONS}/*.proto")
If I run my cmake without add_jar command, it successfully run and generate java files in the respective folders. But, if I add add_jar
add_jar(${JAR_NAME} ${JAVA_SOURCES})
The above instruction fails with the following error message.
Scanning dependencies of target ProtoJava
make[2]: *** No rule to make target '../protoJava/Data.java', needed by 'CMakeFiles/ProtoJava.dir/java_compiled_ProtoJava'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ProtoJava.dir/all' failed
make[1]: *** [CMakeFiles/ProtoJava.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
How to get the jar file created? I tried putting add_jar inside add_custom_command under the same target as java file creation.
add_custom_command(
TARGET lang_java
COMMAND add_jar(${JAR_NAME} ${JAVA_SOURCES}))
but it errors out with message
/bin/sh: 1: Syntax error: word unexpected (expecting ")")
CMakeFiles/lang_java.dir/build.make:57: recipe for target 'lang_java' failed
make[2]: *** [lang_java] Error 2
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/lang_java.dir/all' failed
make[1]: *** [CMakeFiles/lang_java.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
How to fix this one?

You have called ADD_LIBRARY for library pugixml without any source files

I am working on quickrank: https://github.com/hpclab/quickrank. when I compile it I get error
cmake .. -DCMAKE_CXX_COMPLIER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Release
You have called ADD_LIBRARY for library pugixml without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: Cannot determine link language for target "pugixml".
CMake Error: CMake can not determine linker language for target: pugixml
CMake Error: CMake can not determine linker language for target: pugixml
-- Generating done
-- Build files have been written to: /home/students/s4438236/quickrank/build_
s4438236#moss:~/quickrank/build_$ make
make[2]: *** No rule to make target `CMakeFiles/pugixml.dir/build'. Stop.
make[1]: *** [CMakeFiles/pugixml.dir/all] Error 2
make: *** [all] Error 2
I do find source file under the lib\pugixml folder, how can I fix this error?
When you call the add_library CMake command, you must provide source files for this target. If we examine the top-level CMakeLists.txt file, we see where the error is occurring:
# external libraries
file(GLOB_RECURSE pugixml_sources ${CMAKE_SOURCE_DIR}/lib/pugixml/src/*.cpp)
add_library(pugixml STATIC ${pugixml_sources})
The CMake error suggests that the pugixml_sources variable is empty, which hints that the /lib/pubixml may have also been empty. If you initially didn't run the git clone command with --recursive, you would not have gotten the pugixml submodule.
Seeing as you said the pugixml sources are now there, I would suggest deleting your CMake cache and the CMake build folder. Running CMake again from scratch will likely allow it to see the pugixml source files.

g++.exe: #letstr.txt: No such file or directory g++.exe: no input files -first try-

as you know that i'm really a beginner for CodeLite and MinGW, and i don't have any idea how it's works. When i try to build the project, the output said that it's error and i don't know what should i do. I'm using Windows 10.
i simply just follow the steps based on this video for the first try. https://www.youtube.com/watch?v=LGGHxaDxSK4
when i want to apply for some installation, the bar always show up like this
http://sta.sh/015gez4rfjn0
i even try to mark mingw32-gcc-g++
let me show you my output
C:\Windows\system32\cmd.exe /C C:/MinGW/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ letstr - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/asu/Documents/letstry/letstr'
C:/MinGW/bin/g++.exe -o ./Debug/letstr #"letstr.txt" -L.
g++.exe: #letstr.txt: No such file or directory
g++.exe: no input files
mingw32-make.exe[1]: *** [Debug/letstr] Error 1
letstr.mk:78: recipe for target 'Debug/letstr' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/asu/Documents/letstry/letstr'
Makefile:4: recipe for target 'All' failed
mingw32-make.exe: *** [All] Error 2
====1 errors, 0 warnings====
g++.exe: #letstr.txt: No such file or directory
i think your destination file incorrect. if you create C program it must be named with .c extension instead of .txt.

Target file fails during INSTALL stage with CMake

I have a CMakeLists.txt file that is building a shared lib as en ExternalProject and this lib needs to be installed in a specific location so that it can be picked up by the main project at build time. I am using the following line to perform the install process:
install(FILES $<TARGET_FILE:of_shared> DESTINATION oF/lib)
However, this fails:
Install the project...
-- Install configuration: ""
CMake Error at cmake_install.cmake:31 (FILE):
file INSTALL cannot find
"/Users/me/packages/builds/x86_64/of-0.9.3-osx-release/$<TARGET_FILE:of_shared>".
make[3]: *** [install] Error 1
make[2]: *** [of_shared-prefix/src/of_shared-stamp/of_shared-install] Error 2
make[1]: *** [CMakeFiles/of_shared.dir/all] Error 2
make: *** [all] Error 2
This might be a compatibility bug of some sort, maybe between CMake versions. I am using CMake 2.8.12.
These are the related CMake lines:
add_library(core OBJECT ${OF_SOURCE_FILES})
add_library(of_shared SHARED $<TARGET_OBJECTS:core>)
set_target_properties(of_shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set_target_properties(of_shared PROPERTIES OUTPUT_NAME openFrameworks)
target_link_libraries(of_shared ${OF_CORE_FRAMEWORKS} ${OF_ADDON_FRAMEWORKS} ${OF_CORE_LIBS} ${OF_ADDON_LIBS})
install(FILES $<TARGET_FILE:of_shared> DESTINATION oF/lib)
install(FILES libs/fmodex/lib/osx/libfmodex.dylib DESTINATION oF/lib)
install(DIRECTORY libs/glut/lib/osx/GLUT.framework DESTINATION .)
Obviously that bit with the $<TARGET_FILE:of_shared> is failing. Apart from that, everything is working. I can see the shared lib being created.
I have found the solution myself. Instead of using:
install(FILES $<TARGET_FILE:of_shared> DESTINATION openFrameworks/lib)
One should use:
install(TARGETS of_shared LIBRARY DESTINATION openFrameworks/lib)
In that case of_shared is the name of the library.

Running Cmake built executables with shared library dependencies

I have a Cmake executable that has been created using ADD_EXECUTABLE.
The executable needs (links to) shared libraries that have been created
also part of the project.
As a final step I want to run this executable as part of the build process to
create some additional files for the build.
so
ADD_EXECUTABLE(foo)
ADD_CUSTOM_COMMAND(OUTPUT out1
WORKING_DIRECTORY dir1
COMMAND foo args
...)
However when the custom command runs it gives an error
.../foo: error while loading shared libraries: libbar.so.1: cannot open shared object file: No such file or directory
make[2]: *** [out1] Error 127
make: *** [all] Error 2
The problem is that the LD_LIBRARY_PATH is not set for the executable to load the library
libbar.so.1. How do in a cross-platform manner set the load library settings in cmake.
I don't want to use RPATH because it actually embeds those paths in the executable, which I
don't want.