inlining failed in call to always_inline ‘_mm_mullo_epi32’: target specific option mismatch

A general method to find the instruction switch for gcc File intrin.sh: #!/bin/bash get_instruction () { [ -z “$1″ ] && exit func_name=”$1 ” header_file=`grep –include=\*intrin.h -Rl “$func_name” /usr/lib/gcc | head -n1` [ -z “$header_file” ] && exit >&2 echo “find in: $header_file” target_directive=`grep “#pragma GCC target(\|$func_name” $header_file | grep -B 1 “$func_name” | head … Read more

Can OpenCV for Android leverage the standard C++ Support to get native build support on Android Studio 2.2 for Windows?

It seems you already have imported the opencv module, now, open your CMakeList.txt and add the follow lines: set(CMAKE_VERBOSE_MAKEFILE on) add_library(lib_opencv SHARED IMPORTED) set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION path-to-your-project/MyApplication/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so) include_directories(path-to-opencv-directory/OpenCV-android-sdk/sdk/native/jni/include) set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=gnu++11”) and edit the: target_link_libraries( # Specifies the target library. native-lib lib_opencv # Links the target library to the log library # included in the … Read more

How to print all the properties of a target in cmake?

I have had limited success with the following work-around to the apparent lack of ability to dynamically query for the properties of a target. I invoke the cmake command to list all properties, and then try each one on the target. # Get all propreties that cmake supports if(NOT CMAKE_PROPERTY_LIST) execute_process(COMMAND cmake –help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST) … Read more

CMake and finding other projects and their dependencies

Easy. Here is the example from the top of my head: The top level CMakeLists.txt: cmake_minimum_required(VERSION 2.8.10) # You can tweak some common (for all subprojects) stuff here. For example: set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) set(CMAKE_DISABLE_SOURCE_CHANGES ON) if (“${CMAKE_SOURCE_DIR}” STREQUAL “${CMAKE_BINARY_DIR}”) message(SEND_ERROR “In-source builds are not allowed.”) endif () set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_COLOR_MAKEFILE ON) # Remove ‘lib’ prefix for … Read more

Linking GLEW with CMake

Typical CMake scripts like FindGLEW will define variables that specify the paths and files that your project needs. If the script can’t automatically identify the correct paths (usually because of nonstandard install location, which is fine), then it leaves these variables up to you to fill in. With command line CMake, you use the -D … Read more

CMake: how to change compiler for individual target

NOTE Some have reported that this doesn’t work for them. It definitely used to work for the project I was working on at the time, which was using CMake’s Makefile generator on Ubuntu. It’s possible this technique (hack?) only works with CMake’s Makefile generator, so if you’re using Ninja or another generator, that might be … Read more

How to change the build type to Release mode in cmake?

To change the build type, on Windows, it must be done at build time: cmake –build {DIR} –config Release By default it’s Debug. I’m still looking for a way of changing this default. CMAKE_BUILD_TYPE doesn’t work of course, and tweaking CMAKE_CONFIGURATION_TYPES doesn’t work either, obviously for the same reason, they only apply for Unix makefiles, … Read more

Why is a variable value not available after add_subdirectory-ing a CMakeLists.txt that defines it? How can I make it so?

As mentioned in the documentation of the set command, each directory added with add_subdirectory or each function declared with function creates a new scope. The new child scope inherits all variable definitions from its parent scope. Variable assignments in the new child scope with the set command will only be visible in the child scope … Read more