Can I build FileCheck and Not in llvm independently? - llvm

When I build klee-2.3,it hint me that there are no FileCheck and not in dir ${LLVM_DIR}$/bin, the LLVM I use is directly downloaded release instead of built from.
So I check that there are FileCheck and not in dir llvm-project/llvm/utils. And there is only one cpp file in FileCheck and not
so could I simply build the cpps into executable file FileCheck and not instead of build with LLVM because it is very time-consuming?
if I could, how do I modify cmakelist.txt?

Related

How to always re-generate version header file when underlying VERSION text file changes using CMake?

I maintain a C++ framework/library that uses CMake as its build system. The framework's version is reflected in a file called VERSION (as in many open source libraries).
I would like to generate a C++ header file with a version string, using VERSION as input. I also want this to happen during a re-build, not just when recreating project files. It would be desirable if VERSION was a dependency so the header file is created only when VERSION has changed.
I am familiar with the technique using the file() command in CMake to read the contests of VERSION, e.g.
file(STRINGS "VERSION" FRAMEWORK_VERSION)
And then generating a file using the configure_file command, e.g.:
configure_file(version.h.in version.h)
But this only generates the header file during the generation of project files. If the VERSION file is changed, the version header file will not be re-generated when re-building (i.e. running cmake --build .).
I know I can use like a Python script run as a CMake macro and always create the version header during the build, but I find it a bit annoying.
What is the best practice here?
Isn't it possible to solve this by only using CMake?
One CMake-only solution is to wrap the commands you suggested in a custom target to run a CMake script. If you make your library depend on the custom target, it will behave per the following:
Generates version.h at compile-time, before building your library.
Only re-generates version.h if its contents will change (new version number or new template file, version.h.in)
The script (let's say VersionHeader.cmake) for the custom target will read the version number from the VERSION file, and generate a new version.h file if necessary. The script can look like this:
file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION" FRAMEWORK_VERSION)
configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in ${CMAKE_CURRENT_LIST_DIR}/version.h #ONLY)
Then, in your CMakeLists.txt file, define a custom target to run a script:
add_custom_target(VersionHeader
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/VersionHeader.cmake
)
add_dependencies(MyFrameworkLib VersionHeader)

Compile a single file under CMake project?

I'm developing a C++ project which is going to be enclosed on a bigger one.
I've seen that on the bigger project (is a Qt application and it's being generated from qmake) I am able to compile a single file from the linux command line, just entering the relative path to the specific file as an argument to make.
On the other hand, I'm using CMake for my own project. When I modify some code for a compilation unit and I have to modify its header file, I have to wait a long time to compile its dependencies and then its own source file. But there are some situations in which I would prefer to check whether the source code in the *.cc file is compilable without errors.
Is there a way to generate a Makefile from CMake the way qmake does this? Switching to qmake is not an option anymore.
You do not have to add extra custom targets to your CMake scripts, as the Makefiles generated by CMake already contain .o targets for each .cc file. E.g. if you have a source file called mySourceFile.cc, there will be a Makefile in your build directory that defines a target called <Some Path>/mySourceFile.cc.o. If you cd into your build directory, you can use grep or ack-grep to locate the Makefile that defines this target, then cd into that Makefile's directory and build it.
E.g. suppose the command ack-grep mySourceFile.cc.o prints something like:
foo/bar/Makefile
119:x/y/z/mySourceFile.o: x/y/z/mySourceFile.cc.o
123:x/y/z/mySourceFile.cc.o:
124: # recipe for building target
Then you can build mySourceFile.cc.o by doing:
cd foo/bar && make x/y/z/mySourceFile.cc.o
CMake doesn't have a generic built-in way of doing this (it's an open issue), but if you're using the Ninja generator, you can can use a special Ninja syntax for building just the direct outputs of a given source file. For example, to compile just foo.o you would use:
ninja /path/to/foo.cpp^
Not out-of-the box. CMake does not expose those "internal" makefile rules in the main makefile.
You can do this only if you consider what kind of file structure CMake uses internally. You can e.g. for compiling a single .obj files using CMake generated makefiles call
make -f CMakeFiles/myProg.dir/build.make CMakeFiles/myProg.dir/main.cc.obj
when you have something like
cmake_minimum_required(VERSION 3.1)
project(myProg CXX)
file(WRITE "main.cc" "int main()\n{\nreturn 0;\n}")
add_executable(myProg main.cc)
To build src/foo.cpp alone:
cmake --build . --target src/foo.cpp.o
No, CMake does not offer built-in support to compile single files.
You have to add a target for each object file, maybe by a function iterating over all files of a directory.
Others have suggested ways to find the target name (ending in .cpp.o) from the .cpp filename, but if you already know the name of a target that will trigger compilation of the .cpp file and you're using ninja this suggestion should be easier.
First build the target:
ninja TriggersCppCompilationLib
Assuming your file was changed or was not yet built, ninja will print the full target name. When you see the name come up, hit enter so it is not overwritten. Then simply copy the name from the terminal (e.g. using tmux copy mode).

how to make superlu in windows

I have downloaded armadillo 6.5. it needs superLU(4.3) library to solve sparse matrix system of equations.
I have downloaded superlu from here but when i want to make it in windows, it gives:
( cd SRC; make )
process_begin: CreateProcess(NULL, ( cd SRC; make ), ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:36: recipe for target 'superlulib' failed
make: *** [superlulib] Error 2
if i cd to SRC directory manually and do make in there, a lot of *.o file is created but again i get this error:
ar cr /Codes/SuperLU/SuperLU_4.3/lib/libsuperlu_4.3.a \
sgssv.o sgssvx.o ssp_blas2.o ssp_blas3.o sgscon.o slangs.o sgsequ.o slaqgs.o spivotgrowth.o sgsrfs.o sgstrf.o sgstrs.o scopy_to_ucol.o ssnode_dfs.o ssnode_bmod.o spanel_dfs.o sp
anel_bmod.o sreadhb.o sreadrb.o sreadtriple.o scolumn_dfs.o scolumn_bmod.o spivotL.o spruneL.o smemory.o sutil.o smyblas2.o sgsisx.o sgsitrf.o sldperm.o ilu_sdrop_row.o ilu_ssnode_dfs.o
ilu_scolumn_dfs.o ilu_spanel_dfs.o ilu_scopy_to_ucol.o ilu_spivotL.o sdiagonal.o superlu_timer.o util.o memory.o get_perm_c.o mmd.o sp_coletree.o sp_preorder.o sp_ienv.o relax_snode.o
heap_relax_snode.o colamd.o ilu_relax_snode.o ilu_heap_relax_snode.o mark_relax.o mc64ad.o qselect.o lsame.o xerbla.o slacon.o slamch.o
ar: /Codes/SuperLU/SuperLU_4.3/lib/libsuperlu_4.3.a: No such file or directory
Makefile:117: recipe for target 'single' failed
make: *** [single] Error 1
i almost have no experience with "make" and "superlu". how can i make superlu in windows? is there any precompiled superlu library available for windows?
Well, it seems that makefile is written for linux systems.
I could do three thing:
follow the instructions on superLU FAQ page:
This was tested in MS Visual Studio. However the configuration highly
depends on which compiler you using. Normally there is an IDE
(Integrated Development Environment) editor associated with your
compiler. You can do it in two steps:
Step I: Create SuperLU library file
Create a new project, then include all the .c and .h files in SRC directory (they can be put in two folders of the IDE).
Change the property of the project to make the output as Library file .lib (not .exe or .dll file).
Compile the project to produce the library file, e.g. superlu.lib. (after you successfully compile it, you can build a
release version without the debug information).
Step II: Build your own application Create a new project with your own
source files which call the SuperLU routines.Add the SRC directory and
the directory where superlu.lib is located to the include path and
library searching path respectively.
Add superlu.lib as the link optional library.
Compile your own .dll or .exe file. Then you are done.
If you are using a compiler with command line only, you have to play
with the makefile or -I -L -O -c options. As SuperLU calls BLAS
routines but BLAS is not a native library of MS Visual Studio, you
have to build your own BLAS library in the similar way as SuperLU
library. The SuperLU distribution includes a C version of BLAS in
SuperLU/CBLAS directory. This version is only functional but not fast.
For speed, it's better to use vendor-supplied BLAS (e.g., Intel MKL)
or public domain versions (e.g., ATLAS, or Goto BLAS).
i could not do it right.
rewrite the whole makefile for windows(i couldn't do it either because i dont know how to write a makefile)
And finally the working solution(for me):
I found a repo in github that added superLU build support for windows!
you can find it here
it has a Visual Studio(2010) solution file that builds the library and gives a lib file.

cmake: You have called ADD_LIBRARY for library cryptopp without any source files

Windows 64bit using cmake to compile c++ project: github.com/iHateInventNames/synergy-through-usb
I fixed a previous issue in this post: Compile issues: LIBUSB_1 with cmake project on Windows
So when I hit cmake now I get the following error:
> cmake .
-- Found libusb-1.0:
-- - Includes: C:/local/libs/libusbx
-- - Libraries: C:/local/libs/libusbx/libusb-1.0.lib
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
-- Generating done
-- Build files have been written to: C:/local/projects/synergy-usb/synergy-through-usb-master
What does this mean? how can I solve it / move on?
Links to the install instructions
both goto 404 errors...
http://synergy-project.org/projects/synergy/wiki/Readme/?hl=pm
http://synergy-project.org/projects/synergy/wiki/Compiling/?hl=pm
Based on a quick browse through the project's CMakeLists, it would seem you're supposed to unpack tools/cryptopp562.zip into a directory called tools/cryptopp562 before running CMake. This should definitely have been mentioned in the projects' installation instructions, if any.
More precisely, the file tools/CMakeLists.txt contains this code:
set(cpp_dir cryptopp562)
file(GLOB cpp_src ${cpp_dir}/*.cpp)
# ...
add_library(cryptopp STATIC ${cpp_src})
This means that the variable cpp_src is filled with source files taken from directory cryptopp562 (relative to the CMakeList's directory, i.e. tools), and is then used to define the source files of library cryptopp. However, the project's distribution only contains tools/cryptopp562.zip. Unpacking that into directory tools/cryptopp562 should provide the missing files.

How to pick source from build dir if available otherwise use source dir?

is there a way to force CMAKE pick sources form current build folder if file(s) is available otherwise take it from the source directory?
My project has following structure:
ROOT/lib/a.cpp
/BUILD
the BUILD folder is where I run cmake ... I've got an optional custom target which generates a source BUILD/lib/a.cpp file: cmake generate.
I'd like to build a library in ROOT/lib that automatically picks up the generated source file BUILD/lib/a.cpp in case it exists otherwise use ROOT/lib/a.cpp.
The library is generated with ROOT/lib/CMakeLists.txt in the following way:
add_library(test a.cpp)
(the custom rule is omitted).
you can just use the full path to generated file:
add_library(test ${CMAKE_CURRENT_BINARY_DIR}/a.cpp)
and if file doesn't exists, your custom command will be executed to generate it.
make sure that generated file produced by add_custom_command() and not by add_custom_target().