Menu
  • HOME
  • TAGS

How to compile LLVM against a custom glibc?

vim,cmake,clang,llvm,glibc

Then I also tried LD_PRELOAD As explained here, in order to use custom glibc, you need to set correct --dynamic-linker. I see that you are using --dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux.so.2, but that doesn't look right: you need ld-linux-x86-64.so.2. export LD_PRELOAD='/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2 ... That (preloading of ld-linux) can never work: it's the ld-linux that...

Why does CMake FILE(READ) ignore commas in my file?

cmake

I found out what the problem is : CMake considers my input as a list, in which elements are separated by a comma (;). To avoid that, we have to add quotes to the variable, like this "${MY_VAR}" : message("${CONTENT}") ...

CMake to find path to a file which its name contains a certain string

cmake

OK, after a lot of searching and getting exhausted I finally found a solution. I just need to use the following command: file(GLOB files "Mylib*") Which will create a list named files and adds each file that its name matches the pattern "Mylib*" to it. I really don't know why...

GoogleTest CMake doesn't recognize TEST_F: Like it's not recognizing GTest something

linux,cmake,make,googletest

As πάντα ῥεῖ pointed out, I hadn't actually tried to build the code. When I did I first received a linker error for pthread, so we added the following line the the CMakeLists.txt file: target_link_libraries(OnePrint pthread) Then I tried again to build and received these errors: /home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to...

how to make sure that cmake codes will run after subdirs

c++,cmake

Do not use deprecated command subdirs. Everything works when it is replaced by add_subdirectory

Cmake - not creating the dynamic links

cmake,make

ldd reports what the run-time linker can find. If you see libba.so in the output it means the binary is linked to the library. The "not found" means the run-time linker can't find that library (i.e. you don't have it installed in a normal system location). So you can either...

Static linking usign cmake

c++,cmake,static-linking

If you link dynamically against SFML, which in turn links dynamically against libstdc++, your application will still require the so/dll files for libstdc++ because of SFML. Think of the SFML.dll as a separate executable. That executable has a dynamic runtime dependency on libstdc++. You cannot get rid of that, because...

Two different CMake difinitions

cmake

This is not really related to CMake but more to the C/++ compiler. In the code the difference is the same between : #define MY_DEFINITION and #define MY_DEFINITION 1 Actually there's not need to define a value for a C/++ macro if the only thing you want is to know...

CMake link shared library

cmake

The first parameter to find_library is a variable. So you should use the value of that created and filled out variable in the target_link_libraries: target_link_libraries( application ${abc} ${OpenCV_LIBS}) ...

How do I list the defined make targets from the command line?

cmake

For Makefile generator build environments you could use cmake.exe --build . --target help And there is the graphical output solution (example found here): cmake.exe . --graphviz=test.graph dotty test.graph See also Generating Dependency Graphs with CMake and CMake Graphviz Output Cleaner. If you don't have dotty installed, you can still make...

How to install shared library and include files manually in linux?

linux,opencv,cmake,raspberry-pi

As a work around, I created tbb.pc file to /usr/lib/pkgconfig/. Here is a sample of that file. https://github.com/openembedded/meta-oe/blob/master/meta-oe/recipes-support/tbb/tbb/tbb.pc Change prefix, libdir and include dir path according to your own tbb path and you're good to go. Hope it helps....

cmake add_custom_command and DEPENDS/TARGET

cmake,add-custom-command

Please use POST_BUILD option. From the cmake documentation: add_custom_command(TARGET target PRE_BUILD | PRE_LINK | POST_BUILD COMMAND command1 [ARGS] [args1...] [COMMAND command2 [ARGS] [args2...] ...] [WORKING_DIRECTORY dir] [COMMENT comment] [VERBATIM]) This defines a new command that will be associated with building the specified target. When the command will happen is determined...

CMake: Adding command line arugments to project

cmake,command-line-arguments

CMake has no built-in support for this. The reason is that the settings from the Debugging tab of Visual Studio Project properties are not stored in the project file (.vc[x]proj), but in a user-and-machine-specific .user file, and CMake does not generate these. You can code it yourself in CMake (I...

CMake cannot find a static library using relative file paths

c++,linker,cmake,allegro

The way I'd recommend is to use the absolute path. I'm not sure why you see this as far from ideal; it's trivial to achieve: target_link_libraries(AllegroTest ${CMAKE_CURRENT_SOURCE_DIR}/lib/liballegro-5.0.10-static-mt.a ${CMAKE_CURRENT_SOURCE_DIR}/lib/liballegro_acodec-5.0.10-static-mt.a etc. ) ...

Excluding lines containing a specific string from REGEX REPLACE in CMake

regex,replace,cmake,exclude,ogre

CMake's regex syntax and documentation are pretty limited. I'd favour turning the file's contents into a list of strings, each string being a line in the file. Iterating these makes the regex much simpler: set(SourceFile "${CMAKE_SOURCE_DIR}/cfg/resources.cfg") file(READ ${SourceFile} Contents) # Set the variable "Esc" to the ASCII value 27 -...

make error during building webkitgtk

linux,makefile,cmake,make

as you see, in Edit1, you (make) try to run JavaScriptCore-4.0.gir instead of compile it with g-ir-compiler; I tried on my pc and my command is: cd /home/davide/src/webkitgtk-2.8.3/build/Source/JavaScriptCore && \ /usr/bin/g-ir-compiler /home/davide/src/webkitgtk-2.8.3/build/JavaScriptCore-4.0.gir \ -o /home/davide/src/webkitgtk-2.8.3/build/JavaScriptCore-4.0.typelib as a workaround, you cand edit: build/Source/JavaScriptCore/CMakeFiles/JavascriptCore-4-gir.dir/build here's the lines on my file (the last...

How to use different tool chains

cmake,cross-platform

The 'one build type and platform per CMake run' limitation is fundamental and I would strongly advise against trying to work around it. The proper solution here seems to me to split the build into several stages. In particular, for the scenario where a target from one build type depends...

Error : Cmake can't generate openCV

opencv,cmake,codeblocks

just do the obvious thing, and specify your c, c++ compiler and the make tool in question: cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM="D:/Programme/MinGW/bin/mingw32-make.exe" -DCMAKE_CXX_COMPILER="D:/Programme/MinGW/bin/mingw32-g++.exe" -DCMAKE_C_COMPILER="D:/Programme/MinGW/bin/mingw32-gcc.exe" -DWITH_IPP=OFF .. (ofc. your path will vary, but i hope, you get the idea) ((if you read between the lines - the opencv devs seem to...

How can LD_LIBRARY_PATH be changed within CMake?

cmake,shared-libraries,dynamic-linking

If your shared lib is not build in the same CMake project of your executable, you can use the CMake rpath handling like this: set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) When you will run make install, CMake will automatically set the runtime path of your executable to your shared library. If your shared library...

Add LLVM to project using cmake

c++,cmake,llvm,llvm-c++-api,llvm-3.0

As indicated by Marco A. in the comments, the problem were missing libraries. This link helped resolve the issue, and everything seems to be working normally now. http://stackoverflow.com/a/25783251/1938163 Thank you....

CMake link library from subdirectory

c++,gcc,linker,cmake,sfml

This should just work. Tried the following with Visual Studio generator on Windows and Makefile generator on Linux on CMake 3.2: project(test) cmake_minimum_required(VERSION 2.8) add_subdirectory(SFML-2.2) add_executable(foo bar.cpp) target_link_libraries(foo sfml-system) SFML is built correctly and foo links correctly to sfml-system. The fact that you build your executable from another subdirectory should...

Cmake test : was a library compiled/linked against libc++ or libstd++?

c++,cmake,libstdc++,libc++

For shared libraries you can use the GetPrerequisites standard module to test if the library depends on libstc++ or libc++. For example, the following code test if boost's program_options library has been compiled against libstc++ or libc++: set (_library "/usr/local/lib/libboost_program_options.dylib") set (_prequesites "") set (_exclude_system FALSE) set (_recurse FALSE) set...

What is the name of CMake's default build target?

c++,c,build,cmake

The default build target does not exist as a CMake target at CMake configure time. It is only exists in the generated build system. Therefore it is not possible to have the default target depend on a custom target.

Protobuf cannot be linked on ubuntu

c++,ubuntu,linker,cmake,protocol-buffers

As @frymode pointet out in his comment, linkage to NewGeneratedMessageReflection means that the compiler generated code that uses Protobuf version 3 (as I used that version in my .proto files). However, the library files installed from the ubuntu package pulled version 2 onto my system, that's why the methods could...

Building Poco C++ libraries on Windows from commandline

visual-studio,cmake,poco-libraries

For Windows you will find preconfigured scrips for building POCO using specific VS compiler version i.e. build_vs120.cmd or generic one buildwin.cmd which you can configure according to what you need: C:\dev\workspace\poco-1.6.0>buildwin.cmd Usage: ------ buildwin VS_VERSION [ACTION] [LINKMODE] [CONFIGURATION] [PLATFORM] [SAMPLES] [TESTS] [TOOL] VS_VERSION: "90|100|110|120" ACTION: "build|rebuild|clean" LINKMODE: "static_mt|static_md|shared|all" CONFIGURATION: "release|debug|both"...

CMake and CTest: automatically run test's dependencies

c++,c,testing,cmake,ctest

There's no built-in way of doing this as far as I know. The best way I can think of to achieve your goal is to use the LABELS property on the tests. You can retrieve the list of dependencies using get_property or get_test_property and apply the same label to testX...

CMake custom builds issues

build,cmake,emscripten

It seems the contents of glue_wrapper.cpp don't depend on build-time values at all, they're based purely on information available at CMake time (the contents of the my_header_files variable). Therefore, you can create the file at CMake time with a simple file() command: file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/interface/glue_wrapper.cpp) # erase file if it exists...

Clion and CMake messages

cmake,clion

use message(WARNING ...) instead of message(...) Warnings go to stderr

Cross compile stunnel

linux,makefile,cmake,arm,cross-compiling

General idea: The openssl-cmake project uses CMake build infrastructure. Hence just specifying the toolchain worked for you. I looked at stunnel source code and they use the traditional GNU Autotools for the build infrastructure which means you cannot use cmake directly on that project. (./configure && make && make install)...

Google Test separate project - How to get tests running against the C++ project

c++,cmake,googletest,clion

The problem seems to be the organization of your code modules. Supposed you have a c++ target project, that provides an executable program as it's final output: I suppose you want to create two executable artifacts your final application a test runner application that runs all test cases you have...

How to deal with libraries like Boost when cross compiling for arm?

ubuntu,cmake,g++,cross-compiling,beagleboneblack

Yes, you need the boost libraries which are not header only built for ARM. This SO question covers that: cross compile Boost 1.57.0 on ubuntu for arm To make things like find_package work for cross compilation you should set CMAKE_FIND_ROOT_PATH. Suppose you set CMAKE_FIND_ROOT_PATH to /opt/beagleboard. CMake will then look...

Use shell command as INSTALL_COMMAND to ExternalProject_Add

shell,cmake

Direct Answer: install(CODE "execute_process(...)") The SCRIPT and CODE signature: install([[SCRIPT <file>] [CODE <code>]] [...]) The SCRIPT form will invoke the given CMake script files during installation. If the script file name is a relative path it will be interpreted with respect to the current source directory. The CODE form will...

Cant include /usr/include/linux files

c++,linux,cmake

@drescherjm was right, I should have gotten read access to that folder. I knew it was a basic question but my knowledge of linux never got into the areas of /usr/include ;)

Building vtk with QT5 windows 8

windows,cmake,qt5,vtk

Did you do step 3 and 4 here? : Combining Qt 5.4.1 with vtk 6.2.0 (using CMake GUI 3.2.1) on windows I'm guessing you didn't change VK_QT_VERSION to 5...

Include QtMultimedia (or whatever is needed for QSound) module using CMake

qt,cmake

Converting my comment into this answer to close this question: CMake needs to know where the Qt5 specific files are located. Therefore you should add ~/sw/Qt/Qt_5_4/5.4/gcc_64/ either to the environment variable $CMAKE_PREFIX_PATH or set it using set(CMAKE_PREFIX_PATH "~/sw/Qt/Qt_5_4/5.4/gcc_64/") Then CMake will be able to perform find_package(Qt5Multimedia)....

SFML not linking statically to openal32 (links statically to all other dependencies)

c++,cmake,sfml

I am not a lawyer (and I did not stay at a popular hotel chain last night). The OpenAL implementation they are using is licensed under the GNU Library General Public License (LGPL), version 2. LGPL v2 requires that: If you link a program with the library, you must provide...

How to include a cmake Makefile after a target has been executed?

cmake

To my knowledge, it is not possible to generate CMakeLists.txt file with a custom target/command and use include CMake command with generated CMakeLists.txt The problem is that the include command is called at so-called "Configuration time" (when cmake executable tries to parse all CMakeLists.txt), but the generation of file (CMakeLists.txt)...

Cannot link to sublibrary/internal library/embedded library with CMake's Visual Studio generator

c++,visual-studio,visual-c++,cmake

From your other question, I gather the project is this one. The cause of the problem is that you're building boost_http as a shared library, but you don't export any functions or classes from it. You need to decorate the public API functions/classes with __declspec(dllexport) to make these available to...

CMake fails to find boost libraries (CGAL, Windows)

c++,boost,build,cmake,cgal

Alright, I finally got everything to the state I needed. What follows is essentially a description of how to get the magical libCGAL.dll and libCGAL.a (library files) that you want on Windows 7 with Code::Blocks. I downloaded and installed CMake. I downloaded and installed Boost 1.58.0, with the manual and...

Glew undefined reference linking error

c++,cmake,glew

Fixed it. Somewhere along the lines I had got glu32 which glew was using instead of the windows ones I compiled. Added a reference to glew32 and it worked fine....

CMake does not find CxxTest package

cmake,cxxtest

find_path does not search the current list directory. That is, just because a relative path is reachable from the current CMakeLists.txt, does not mean that it will be found. You can find a complete description of the search order in the manual. A quick and dirty solution is to add...

cmake - Is it possible to link executable to shared library with relative path at runtime?

c++,cmake,shared-libraries

When you launch ldd to check your app shared library dependencies, it always prints absolute paths. But if you are using the -rpath oprtion together with the $ORIGIN variable, everything will work as you expect. You can move the executable and the shared library, remove the original build directory and...

How do I create a project in Visual Studio to use OpenMesh after I've built using CMake?

c++,visual-studio,cmake

Open the file using visual studio (By double clicking on it.) Once visual studio opens find the Build tab at the top of the window. Hit the build solution button and wait for the compiler to finish. To change the build configuration find the drop down menu beside the...

cmake target_link_libraries() launching error Cannot specify link libraries for target “debug”

c++,api,cmake,sfml

EXECUTABLE_NAME is not set in target_link_libraries command, so in a debug build target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES}) is expanded to target_link_libraries(debug path/to/debug/library optimized path/to/release/library ... ) The first argument is treated as target name so you see the error Error:Cannot specify link libraries for target "debug" which is not built by this project...

Link target to libraries

makefile,cmake,mingw,cmake-gui

CMakeLists.txt should call target_link_libraries(cryptopp ws2_32) after command ADD_LIBRARY to resolve undefined references....

Expected build-failure tests in CMake

c++,cmake,automated-tests,ctest

You can do this more or less as you described. You can add a target which will fail to compile, then add a test which invokes cmake --build to try to build the target. All that remains is to set the test property WILL_FAIL to true. So, say you have...

Adding headers to Cmake

compilation,cmake

I see some problems in your CMake file. First of all, your *.h files musn't be given in the add_executable command. Try something like that : cmake_minimum_required(VERSION 2.8) project(RotateActor) option(INCLUDE_SERVER "Use the server implementation" ON) # Manage your libraries before your sources find_package(VTK REQUIRED) include(${VTK_USE_FILE}) # add the Server library...

Strip filename (shortest) extension by CMake (get filename removing the last extension)

cmake

I'd solve this with a simple regex: string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${MYFILE}) set(MYFILE_WITHOUT_EXT ${CMAKE_MATCH_1}) ...

Using Cmake's RelWithDebugInfo as Default Build Type

c++,c++11,build,cmake

The usual drawbacks for debugging optimized builds apply. In particular, the debugger may occasionally lie to you about what the values of variables are. Also it's usually not possible to inspect variables which have been optimized out, which typically affects function parameter and local variables. What's arguably worse is, you...

Building libobjc2 with CMake + Clang + MinGW on Linux

cmake,clang,cross-compiling,mingw-w64,libobjc2

Okay, so I figured that I would need to add -lobjc to the CMAKE_CXX_FLAGS, but it never occured to me to add a linker search path for the library. Running the following before make solves my problem: cmake .. -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS=$CLANG_WINDOWS_XFLAGS -DCMAKE_CXX_FLAGS="$CLANG_WINDOWS_XFLAGS -L`pwd` -lobjc" -DCMAKE_INSTALL_PREFIX=/opt/cross/windows/gnustep ...

CMake issues with trying to include my source files

c++,cmake,sfml,clion

Two suggestions I'm not sure what are you intending to do with the include paths. My guess is that this is a left over from some experimentation. You've told CMake to look in 2 directories, both directories that have a space in them. Because you probably don't have a directory...

CMAKE, SDL2 and OPENGL: Program binary is too big

c++,cmake,shared-libraries,static-libraries,sdl-2

Building with cmake . uses the same CMAKE_BUILD_TYPE as the most recent build in that directory. Use cmake -DCMAKE_BUILD_TYPE=Release . to build in release mode. If you built debug first then release, using the procedure you described, it would just rebuild your debug binary.

c++: Undefined reference to ERROR

c++,cmake,ros,cpd

undefined reference is a linker error, not a compiler error. Your use of include_directories() is OK, but you forgot to also add ${CPD_LIBRARIES} (1)(2) to the target_link_libraries() of your target(s). (1): Just guessing that FindCPD.cmake "works" the same way as all the other FindXyz.cmake modules. Never worked with CPD myself....

CTest not detecting tests

cmake,make,ctest

You need to move the enable_tests() call to be before you do add_subdirectory(tests) # Enable testing for the project enable_testing() add_subdirectory(tests) ...

Linker error while building from source code

c++,cmake,linuxmint

Try passing -DCMAKE_EXE_LINKER_FLAGS=-ldl to the CMake executable. To change the CMake build scripts, add something like: target_link_libraries(target_name dl) where target_name is basically the executable name without any extensions (e.g. .exe). EDIT: Actually, I just reread you question, and I'm putting this in the wrong place. You really want: target_link_libraries(Basic dl)...

Build libfreenect on ubuntu

build,header,cmake,make,openkinect

To find where your library has been built, from the build directory call: find -name \*.so (dynamic libraries, that seems to be the case) or find -name \*.a (static libraries). Anyway, if you do sudo make install, your libraries will be installed in /usr/local/lib as stated in your cmake output....

Install a CMake macro script from within a python package install script (using setup.py)

python,cmake,setuptools,distutils,setup.py

It took me a while to understand your question. If I understand correctly, what you are trying to do is provide the IodSymbolize.cmake in the standard installation location of cmake so that other users/projects who rely on your software(symbolizer) can use it in their build process. I think you are...

Valgrind changes working directory with CTest in KDevelop

c++,cmake,valgrind,ctest

It seems to be a problem with KDevelop. Running the test from the console did not change the working directory. I've created a bug report: https://bugs.kde.org/show_bug.cgi?id=349378...

How can I use CMake to link vtk library to multiple source file?

c++,cmake,vtk

add_executable can be used to choose source files to use for this project. add_executable(test MACOSX_BUNDLE test.cxx test2.cxx test42.cxx) same as SET(CXX_SRC_FILES test.cxx test2.cxx test42.cxx) add_executable(test MACOSX_BUNDLE ${CXX_SRC_FILES}) ...

Cannot link Boost to CMake-based project on VS2015 RC

c++,visual-studio,visual-c++,boost,cmake

The problem is that you define BOOST_TEST_DYN_LINK which according to the Boost.Test docs is used when consuming the dynamically-built Boost.Test lib. Since you have built the static version, you should remove this definition....

CMake error while running tar

cmake

I think you're seeing this CMake bug which was resolved after version 2.8.12.2. I'm not sure whether the fix made it into 3.0.0 or if it was 3.0.1, but either way, if you update CMake to the current version, you should see the problem disappear. (I expect the í character...

What is the location to install .cmake extension files in Ubuntu?

ubuntu,installation,cmake

You can use the CMake package configuration mechanism, which you mentioned in your question. Imaging you have the following CMake files: SomeProjectConfig.cmake SomeProjectConfigVersion.cmake SomeProjectExtensions.cmake The SomeProjectConfig.cmake and SomeProjectConfigVersion.cmake can be generated by CMakePackageConfigHelpers module. You can install them into /usr/share/cmake/SomeProject/ folder, for example. For full list of default paths used...

Unable to build GLFW with CMake errors

c,cmake,glfw

One of the error outputs was Looking for glXGetProcAddressEXT - not found, and the log files indicated that there was a linking error with libGL. I then tried running apt-get install glfw to print out the list of dependencies. Even though it was an older version in apt-get, it still...

Clion: How to properly add images, xml, resources… to cmake

c++,cmake,clion

For this I used the configure_file command in Cmake, so the file is copied to the build directory. It's done every time when the file was modified. configure_file(config.xml config.xml COPYONLY) http://www.cmake.org/cmake/help/v3.0/command/configure_file.html...

Cmake to generate solution file machine independent

cmake,gsl

CMake is not designed to be used in this way, and it is highly unlikely you will be able to use it in this way. CMake performs system introspection, storing this in the CMake cache, and uses full paths to most things. I would advise you to run CMake on...

How do I make cmake output fortran .mod files into a mod dir?

cmake,fortran

See target's property Fortran_MODULE_DIRECTORY or CMAKE_Fortran_MODULE_DIRECTORY.

cmake command to verify libraries?

c++,linker,cmake

Use the CMake standard module GetPrerequisites. Example: include(GetPrerequisites) set (_recurse TRUE) set (_exclude_system FALSE) set (_verbose TRUE) list_prerequisites("/usr/lib/libc.dylib" ${_recurse} ${_exclude_system} ${_verbose}) ...

How to avoid name clashes in cmake subprojects?

cmake

CMake doesn't allow duplicate target names. The rationale is provided in the docs for policy CMP0002: Unique names may be referenced unambiguously both in CMake code and on make tool command lines. Logical names are used by Xcode and VS IDE generators to produce meaningful project names for the targets....

How to write CMakeFile when the code use C++, but called python

python,c++,linux,makefile,cmake

This should be sufficient: find_package(PythonLibs REQUIRED) add_executable(outxx main.cpp pu.cpp) target_link_libraries(outxx ${PYTHON_LIBRARIES}) target_include_directories(outxx PUBLIC ${PYTHON_INCLUDE_DIRS}) And if we were to try and run this: [2:28pm][[email protected] blah] cmake . -- The C compiler identification is AppleClang 6.1.0.6020053 -- The CXX compiler identification is AppleClang 6.1.0.6020053 -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc...

How to get IDE setup running for CustusX for plugin development?

cmake

CustusX is configured using the superbuild cxInstaller.py. As part of this build, cmake is invoked with parameters: cmake arguments source_folder An example when located in the build folder /home/cas/cx/CX/build_Release: cmake -G"Eclipse CDT4 - Ninja" -DCMAKE_BUILD_TYPE:STRING=Release -DEIGEN_INCLUDE_DIR:PATH=/home/cas/cx/eigen/eigen -DCTK_DIR:PATH=/home/cas/cx/CTK/build_Release -DOpenCV_DIR:PATH=/home/cas/cx/OpenCV/build_Release ...more arguments omitted... /home/cas/cx/CX/CX This command can be found by looking through...

How can I cmake/make a CGAL binary that correctly links against a libassimp dylib on OSX?

c++,osx,cmake

Found this after asking, which gave me the clues I needed: How to find a library with cmake? Essentially I changed the relevant lines in my CMakelists.txt to read: create_single_source_cgal_program( "sample.cpp" ) target_link_libraries (sample assimp) this works because apparently when you tell cmake to target_link_libraries(EXENAME FOO), it will look for...

How to determine static lib path for boost?

c++,linux,boost,cmake

You may use the find_package feature of CMake. Add the following lines to your CMakeLists.txt: set(Boost_USE_STATIC_LIBS ON) find_package(Boost COMPONENTS boost_system REQUIRED) link_libraries(${Boost_LIBRARIES}) Please see also: http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html...

CMake creating shared and static library with different defines

cmake

You can set compiler flags per-target by using the target_compile_definitions command. For example: target_compile_definitions(support PRIVATE MY_SHARED_DEFINITION) target_compile_definitions(support_s PRIVATE MY_STATIC_DEFINITION) As for adding a postfix to your debug libraries, you can achieve this by setting the CMake variable CMAKE_DEBUG_POSTFIX: set(CMAKE_DEBUG_POSTFIX _d) This will cause all non-executable targets to have _d appended...

CMake simple MVC structure

c++,model-view-controller,cmake

It looks pretty normal structure to me. In fact I use the same one in my projects. In the root CMake file you will put: include(Src/Model/CMakelists.txt) and CMakelists.txt might look like this: set(MODEL_HEADERS src/Model/model.hpp) set(MODEL_SOURCES src/Model/model.cpp ${MODEL_HEADERS}) list(APPEND ALL_SOURCES ${MODEL_SOURCES}) source_group("Model" FILES ${MODEL_SOURCES}) Where ALL_SOURCES is the variable from the...

How to use cmakedefine preprocessor directive properly?

c++,cmake

You should include not "headerconfig.h.in", but "headerconfig.h", and add appropriate configure_file call in your cmake. The idea is that cmake process headerconfig.h.in and generate headerconfig.h, replace "#cmakedefine" with real values, and it uses headerconfig.h.in as template.

How to install SDL dev library so CMake can find it

cmake,sdl

I read a bit on the wiki page and found a slight workaround. I don't think it's perfect but it's fine for now. cmake -G "Visual Studio 12 2013 Win64" -D SDL_LIBRARY_TEMP=%SDLDIR%\lib\x64\SDL2.lib .. This correctly find SDL2 although I am running into another issue, but I will make a new...

How to change the name of the output binary to not be a.out with CMake?

cmake

Here's a simple CMakeLists.txt cmake_minimum_required(VERSION 2.6 FATAL_ERROR) project(demo) add_executable(hello hello.cpp) This CMakeLists.txt compiles a hello.cpp file to an executable named hello. You can name the executable anything by using the add_executable statement. add_executable(<executable-name> <source1> <source2> ...) ...

Statically Linking Lua in Cmake

c++,lua,cmake

I finally got it to work (some other errors were getting in the way). The aforementioned line copies the generated luaconf.h file to the binary directory, now instead I just copy it to the source directory: configure_file ( src/luaconf.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/luaconf.h ) ...

How to set target library dynamically in cmake?

c++,boost,cmake

The correct library name should already be provided through FindBoost. Just use it like this: find_package(Boost COMPONENTS thread) include_directories(${Boost_INCLUDE_DIRS}) add_executable(foo foo.cpp) target_link_libraries(foo ${Boost_LIBRARIES}) ...

cmake disable optimization with /Od

cmake

You need to modify CMAKE_CXX_FLAGS_RELEASE, for example: STRING(REPLACE "-O2" "-Od" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) ...

How can I configure CMake generated Eclipse project's Build Command and Project Paths?

cmake,eclipse-cdt

I found a solution to build command issue. When you run cmake to generate the eclipse project include the additional argument:-DCMAKE_ECLIPSE_NINJA_ARGUMENTS=-j100. I haven't confirmed but I believe a similar command is required for eclipse make projects -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j100. Unfortunately this feature is poorly documented and I have not found a solution...

Do you only need to build the googletest library once?

c++,cmake,make,static-libraries,googletest

You should keep in mind that make will not rebuild gtest if you don't change anything in gtest source code. Below is my approach to the usage of cmake and gtest for unit testing. You can add gtest source code by adding it as subdirectory in the root CMakeLists.txt file....

Cmake errors: The CXX Compiler identification is unknown, The C compiler identification is unknown

c++,opencv,cmake,arm,cmake-gui

From the output it appears that cmake was able to find your cross compiler but as the output says it can't compile a simple program. I would start with creating Hello World in C++ and trying to compile that with your cross compiler. If that doesn't work that is your...

Clang linker says symbols undefined [duplicate]

c++,cmake

Your class is a template. Template code is instantiated on demand when another code needs it. Thus you cannot compile body of your class separately (there's nothing to compile as it's a template and thus linker reports undefined symbols). You have to put implementation of templated classes to header files.

GoogleTest CMake and Make tests not running

c++,linux,makefile,cmake,googletest

I wouldn't normally expect to see makefiles being mixed into a CMake-managed project; it sounds like you have quite a complicated setup? That aside, I think the root cause here is likely to be twofold. I don't think the test executable in /src/tests/ is actually being built. I can't see...

How do I set a variable to point to more than one file

cmake,glew

Use list values, which are separated by semicolons: cmake -DGLEW_LIBRARIES=%GLEWDIR%\lib\Release\x64\glew32.lib;%GLEWDIR%\lib\Release\x64\glew32s.lib And in CMake: target_link_libraries(my_executable ${GLEW_LIBRARIES}) Note that %GLEWDIR% might not get interpreted correctly in this context....

Cmake and Qt5 linking error

c++,qt,cmake,qt5

I think you forget to append moc and resources to your executable use qt5_wrap_cpp() for mocs use qt5_add_resources() for resources. Then you must append vars to add_executable check out this link. ...

CMake - How to create executable, but not add to “all” target?

cmake,target,ctest

Set the EXCLUDE_FROM_ALL flag upon creating the test executable target to exclude the target from the all target: add_executable (Test${TestID} EXCLUDE_FROM_ALL Test${TestID}.cpp) Making sure that the test targets are built before the execution of the tests is more tricky. You cannot add a dependency to the built-in test target with...

Static linking DCMTK library

c++,linux,linker,cmake,dcmtk

Can you check the content of ${DCMTK_LIBRARIES} (it should be a list of paths to DCMTK static libraries) ? you can also check the following CMake entries during the CMake configuration: DCMTK_DIR /path/to/DCMTK/install DCMTK_config_INCLUDE_DIR /path/to/DCMTK/install/include/dcmtk/config DCMTK_dcmdata_INCLUDE_DIR /path/to/DCMTK/install/dcmdata/include/dcmtk/dcmdata DCMTK_dcmdata_LIBRARY_DEBUG /path/to/DCMTK/install/dcmdata/libsrc/libdcmdata.a DCMTK_dcmdata_LIBRARY_RELEASE /path/to/DCMTK/install/dcmdata/libsrc/libdcmdata.a [...] Another...

Having issues with using libraries and CMake

c++,cmake

The error message is pretty clear: There are two targets with the same name which is not possible in CMake. add_executable(Majick ${SOURCE_FILES}) ... add_library(Majick STATIC) I guess the second target just needs to be deleted....

Templated linkage does not work on -O2, but does on -O0

c++,cmake

My issue is solved and dyp was closest with his/her comment. The magic word is "explicit template instanciation" and may be found here: http://www.cplusplus.com/forum/articles/14272/ I did NOT clutter my header files with definitions. Nor did I add code like #include "some.cpp" into the header, which in my opinion amounts to...

Qt Creator does not find Boost via CMake, CMake itself does

boost,cmake,qt-creator

It seems CMake isn't looking in /usr/lib/x86_64-linux-gnu for the libraries. The debug output shows that it's looking in /usr/include/lib;/usr/include/../lib;/usr/include/../lib/;/usr/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib. If you're using an older version of CMake, this may be fixed by upgrading (there has been some recent work done on the FindBoost module I believe). Alternatively, you should be...

Converting Makefiles to CMAKEList (compilation successful but the program behave differently) [closed]

c++,makefile,cmake

From a quick look, your compile flags are not the same. For example, in the Makefile you have CPPFLAGS= -O3 -Wall $(INCDIR) But, in CMakeLists.txt you have set(CMAKE_CXX_FLAGS " -Wall -I./include -I/usr/local/include ") which is missing the "-O3" flag. Make sure the flags are identical. The same goes for the...

How to ask Cmake output googletest detailed result

c++,cmake,googletest

I figured out I can do this: make test ARGS=-V ...

Creating one binary for multiple unit tests in Google's C++ Testing Framework

c++,unit-testing,cmake,googletest

No, you do not need to do anything special with these files... All of your TEST_F and similar macros will be linked together and run. This is googletest magic... Actually you do not need this "test manager source" with main() - just use file from your googletest/googlemock distrubution: gmockxxx/src/gmock_main.cc or...