cmake

cmake detects clang-cl as clang

守給你的承諾、 提交于 2020-05-28 03:45:12
问题 I built boringssl with cmake and msvc Then I tried to build with clang-cl so I used -T"LLVM-vs2014" in vmake arguments Clang-cl uses cl arguments however cmake used gcc style arguments without adding -Xclang 回答1: The proper way to handle this case is checking for (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) 回答2: the problem was here : if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}

How to static linking to glibc in cmake

北慕城南 提交于 2020-05-27 05:15:00
问题 I'm trying to build a package from Fedora that can run on a RedHat 6 machine. So I need to build and static linking with some library that does not exist in RedHat machine. I found that I can you -static-libgcc or -static-libstdc++ to link with static version of standard library but I don't know how to do with glibc . How can I link to static library of glibc with CMake? Sorry for my bad English. 回答1: Since -static-libgcc and -static-libstdc++ are linker options, the correct way to set them

CMake add -ldl at end of link stage of add_library

删除回忆录丶 提交于 2020-05-26 04:47:06
问题 I wrote/maintain a small unit test library on github https://github.com/acgreek/ExtremeCUnit built using cmake. You can checkout and run some tests via 'cmake test' after checking out. It was working great on Cygwin and Ubuntu (my only home systems). I recent upgrade to ubuntu 13.10 and the library stopped linking with the test binary because the ExtremeUnitC library now needs to be linked with -ldl at the link stage (via add_library) and additionally the -ldl needs to be add to the end of

How to build TensorFlow Lite as a static library and link to it from a separate (CMake) project?

佐手、 提交于 2020-05-25 23:46:29
问题 I've successfully built a simple C++ app running TF Lite model by adding my sources to tensorflow/lite/examples , similarly to what the official C++ TF guide suggests for full TF. Now I want to build it as a separate project (shared library) linking to TF Lite statically and using CMake as a build system. I tried to add a custom target to my CMakeLists.txt , which would build TF Lite with Bazel: set(TENSORFLOW_DIR ${CMAKE_SOURCE_DIR}/thirdparty/tensorflow) add_custom_target(TFLite COMMAND

how to link winsock in cmake?

放肆的年华 提交于 2020-05-25 11:27:24
问题 I found only this strings find_library(WSOCK32_LIBRARY wsock32) find_library(WS2_32_LIBRARY ws2_32) (i'm begginer in cmake) how to link winsock2 (winsock?) in cmake? 回答1: Since these are both part of the Windows SDK, you shouldn't need to do a search for them. Assuming you have the SDK installed, you can just do something like: add_executable(MyExe main.cpp) if(WIN32) target_link_libraries(MyExe wsock32 ws2_32) endif() 来源: https://stackoverflow.com/questions/15119639/how-to-link-winsock-in

Building C++ and Java code using CMake and Maven and bundle in a jar

北城余情 提交于 2020-05-24 21:36:28
问题 I have a legacy C++ code that is built using CMake. It generates a .so file. I need to wrap this code in Java and build a jar that includes Java code as well as C++ for deployment. Steps for building C++ code with CMake is simple : cd /to/pkg/dir cmake . make The .so file is generated under a build/ directory. If I convert the whole project into maven, I will have to modify the directory structure (here is a blog that explains how that could work http://blog.bigpixel.ro/2012/07/building-cc

Understanding roles of CMake, make and GCC

喜夏-厌秋 提交于 2020-05-24 14:35:09
问题 1. cmake is a command from CMake software: preparation for build automation system; make and make install are commands from Make software: build automation system. 2. From reading this post, what I understand is that: a. This "cmake and make" stuffs actually use g++ / gcc in its implementation. cmake and make stuffs are basically just tools in using g++ / gcc. Is that correct? b. gcc / g++ are the compiler that do the actual work. c. So I can just use gcc / g++ directly without using the make

CMake : multiple subprojects using the same static library

▼魔方 西西 提交于 2020-05-24 10:14:03
问题 I'm using cmake to compile one of my work projets, here is the deal - client/ CMakeLists.txt server/ CMakeLists.txt libs/ libstuff/ CMakeLists.txt CMakeLists.txt So i want to be able to compile each subproject individually, and build both the client and the server from the root folder. Let's say the client and the server need libstuff. I tried to use "add_subdirectory" with the path of the lib in both client and server CMakeLists.txt, it works when you compile the server or the client, but if

Use variable from CMAKE in C++

左心房为你撑大大i 提交于 2020-05-24 03:27:07
问题 I want to use a value declared in my CMakeLists.txt in my C++ code. I've tried to do like that : ADD_DEFINITIONS( -D_MYVAR=1 ) and #if -D_MYVAR == 1 #define var "someone" #else #define var "nobody" #endif int main(){ std::cout << "hello" << var << std::endl; return 0; } But it doesn't work, and I don't understand why. Maybe I don't use ADD_DEFINITIONS correctly... Ideally, I wish do something like that : ADD_DEFINITIONS( -D_MYVAR=\"someone\" ) and #define var D_MYVAR int main(){ std::cout <<

CMake append objects from different CMakeLists.txt into one library

℡╲_俬逩灬. 提交于 2020-05-23 21:13:25
问题 I would like to create a single library from objects from multiple sub-directories, each one containing their own CMakeLists.txt with OBJECT library trick to have multiple targets with different compile options. Here are the files: project_dir |--- subdir1 | |--- src1.c | |--- CMakeLists.txt |--- subdir2 | |--- src2.c | |--- CMakeLists.txt |--- CMakeLists.txt Contents of all CMakeLists.txt // project_dir/CMakeLists.txt // what to put here? to make one single library (mainLib) // project_dir