It builds fine from console Cmake, but when I try to open the project and build it from Qt Creator I see no targets specified.
Qt Creator version 3.1.1
CMake file
project(wordnetTest)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
INCLUDE_DIRECTORIES(/usr/local/WordNet-3.0/include/ ./wordnet-blast-master)
add_executable(${PROJECT_NAME} ${SRC_LIST})
find_library(LIBWN WN HINTS "/usr/local/WordNet-3.0/lib")
if(NOT LIBWN)
message(FATAL_ERROR "Library `WN` not found")
endif()
target_link_libraries(${PROJECT_NAME} ${LIBWN})
Related
I tried to create a shared library (.so file) for aarch64 device with CMake, however, cmake compiling the scripts with the type of x86-64. What I need is ARM aarch64 format. If anybody knows please help me?
my cmake file :
PROJECT(deepsort)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
cmake_policy(SET CMP0015 NEW)
AUX_SOURCE_DIRECTORY(./errmsg DIR_SRCS_errmsg)
AUX_SOURCE_DIRECTORY(./thirdPart DIR_SRCS_hungarianoper)
AUX_SOURCE_DIRECTORY(./thirdPart/munkres DIR_SRCS_munkres)
AUX_SOURCE_DIRECTORY(./thirdPart/munkres/adapters DIR_SRCS_munkres_adapters)
AUX_SOURCE_DIRECTORY(./matching DIR_SRCS_matching)
AUX_SOURCE_DIRECTORY(./feature DIR_SRCS_feature)
AUX_SOURCE_DIRECTORY(./common DIR_SRCS_common)
AUX_SOURCE_DIRECTORY(./api DIR_SRCS_api)
include_directories(
./errmsg
./thirdPart
./thirdPart/Eigen
./thirdPart/munkres
./thirdPart/munkres/adapters
./matching
./feature
./common
./api
)
add_library(deepsort SHARED
${DIR_SRCS_errmsg}
${DIR_SRCS_hungarianoper}
${DIR_SRCS_munkres}
${DIR_SRCS_munkres_adapters}
${DIR_SRCS_feature}
${DIR_SRCS_matching}
${DIR_SRCS_api}
)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
I solved the problem by putting cxx and c variables in Cmakelists.txt file:
set(tools /usr/bin)
set(CMAKE_C_COMPILER ${tools}/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/aarch64-linux-gnu-g++)
if you want to compile in a different environment then you would have to download chain tools.
I have installed Intel opencl sdk for windows and opencl variable are added to the environment variables. I want to use this sdk with my Clion ide which I am unable to include it in my current project since it was CL/cl.hpp not found. How can add it to my project in Clion?
Cl/cl.hpp is located atC:\Program Files(x86)\IntelSWTools\OpenCL\sdk\include\CL
following is my CMakeLists.txt
project(tpch_framework)
# enable c++11
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE "Release")
find_package(OpenMP REQUIRED)
find_package(OpenCL REQUIRED)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# Configure required Boost libraries
set(BOOST_ROOT "" CACHE PATH "Boost build root (useful on Windows)")
option(Boost_USE_STATIC_LIBS
"Search for static boost libs" OFF)
option(Boost_USE_MULTITHREADED
"Search for multithreaded boost libs" ON)
option(Boost_USE_STATIC_RUNTIME
"Search for boost libs linked against static C++ runtime" OFF)
find_package(Boost 1.47.0 REQUIRED filesystem system)
# ensure that dependant libraries not explicitly specified here
# are found by the linker:
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
#Bring the headers into the project
include_directories(include)
FILE(GLOB_RECURSE INC_ALL "include/*.hpp")
#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")
add_library(tpch_framework ${SOURCES})
add_executable(framework main.cpp ${INC_ALL})
target_link_libraries(framework tpch_framework)
#target_link_libraries(framework stdc++fs)
target_link_libraries(framework ${LIBS})
You need to provide information about include directory for OpenCL headers like you provided for Boost headers. Also, you need to link OpenCL libraries with your target.
In your CMakeLists...
For include and link directories:
link_directories(${Boost_LIBRARY_DIRS} ${OpenCL_LIBRARY})
include_directories(${Boost_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS})
For linking libraries:
set(LIBS ${LIBS} ${Boost_LIBRARIES} ${OpenCL_LIBRARY})
(problem already solved)
It will compile if just $qtcreator openglwindow/openglwindow.pro for Qt5-OpenGL-example(http://doc.qt.io/qt-5/qtgui-openglwindow-example.html)
My CMakelist can be build on Win10, but on linux fail, the command is:
[user]$ mkdir build && cd build && cmake .. && make
it outputs error as follow:
Scanning dependencies of target QtGL_test_automoc
[ 20%] Automatic mocfor target QtGL_test
Generating moc source QtGL_test_automoc.dir/moc_openglwindow_LRW7M26ARLGWDK.cpp
Generating moc compilation QtGL_test_automoc.cpp
[ 20%] Built target
QtGL_test_automoc Scanning dependencies of target QtGL_test
[ 40%] Building CXX object CMakeFiles/QtGL_test.dir/main.cpp.o
c++: fatal error: no input files compilation terminated.
/bin/sh:-DQT_CORE_LIB: command not found
make[2]: *** [CMakeFiles/QtGL_test.dir/build.make:63: MakeFiles/QtGL_test.dir/main.cpp.o] Error 127
make[1]: ***[CMakeFiles/Makefile2:68: CMakeFiles/QtGL_test.dir/all] Error 2 make:
*** [Makefile:84: all] Error 2
I'd tried to figure out how to modify a cross-platform version for linux.
Here is my CMakeLists.txt:
cmake_minimum_required (VERSION 3.5)
set(PRROJ_NAME QtGL_test)
project (${PRROJ_NAME})
set(HEADERS ${HEADERS} openglwindow.h )
set(SOURCES ${SOURCES} main.cpp ${HEADERS})
set(CMAKE_AUTOMOC ON)
add_executable(${PRROJ_NAME} ${SOURCES})
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
add_library(openglwindow openglwindow.cpp)
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} openglwindow)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(WIN32)
find_path(CMAKE_PREFIX_PATH NAMES lib/cmake/Qt5/Qt5Config.cmake HINTS
"$ENV{Qt5_ROOT}"
)
message("Qt5_ROOT is $ENV{Qt5_ROOT}")
endif()
message("CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
set(NEED_QT_COMPONENTS QTCORE QTGUI)
message("finding ${NEED_QT_COMPONENTS}")
foreach(COMPONENT Gui Core)
message("find_package(Qt5${COMPONENT})")
find_package("Qt5${COMPONENT}")
message("Qt5${COMPONENT}_FOUND is ${Qt5${COMPONENT}_FOUND}")
if("${Qt5${COMPONENT}_FOUND}")
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} "${Qt5${COMPONENT}_INCLUDE_DIRS}")
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} "Qt5::${COMPONENT}")
add_definitions("${Qt5${COMPONENT}_DEFINITIONS}")
qt5_use_modules(${PRROJ_NAME} ${COMPONENT})
endif()
endforeach(COMPONENT )
message("include_directories(${PROJ_INCLUDE_DIRS})")
include_directories(${PROJ_INCLUDE_DIRS})
message("target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})")
target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})
set(CMAKE_CXX_STANDARD 14)
if(UNIX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -Wall")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
endif()
finally solved version:
cmake_minimum_required (VERSION 3.5)
set(PRROJ_NAME QtGL_test)
project (${PRROJ_NAME})
set(HEADERS ${HEADERS} openglwindow.h )
set(SOURCES ${SOURCES} main.cpp ${HEADERS})
set(CMAKE_AUTOMOC ON)
add_executable(${PRROJ_NAME} ${SOURCES})
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
add_library(openglwindow openglwindow.cpp)
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} openglwindow)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(WIN32)
find_path(CMAKE_PREFIX_PATH NAMES lib/cmake/Qt5/Qt5Config.cmake HINTS
"$ENV{Qt5_ROOT}"
)
message("Qt5_ROOT is $ENV{Qt5_ROOT}")
endif()
message("CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
set(QT_FLAGS "-fPIC")
set(NEED_QT_COMPONENTS QTCORE QTGUI)
message("finding ${NEED_QT_COMPONENTS}")
foreach(COMPONENT Gui Core)
message("find_package(Qt5${COMPONENT})")
find_package("Qt5${COMPONENT}")
message("Qt5${COMPONENT}_FOUND is ${Qt5${COMPONENT}_FOUND}")
if("${Qt5${COMPONENT}_FOUND}")
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} "${Qt5${COMPONENT}_INCLUDE_DIRS}")
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} "Qt5::${COMPONENT}")
#Open add_definitions will error
#add_definitions("${Qt5${COMPONENT}_DEFINITIONS}")
qt5_use_modules(${PRROJ_NAME} ${COMPONENT})
endif()
endforeach(COMPONENT )
message("include_directories(${PROJ_INCLUDE_DIRS})")
include_directories(${PROJ_INCLUDE_DIRS})
message("target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})")
target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})
set(CMAKE_CXX_STANDARD 14)
if(UNIX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QT_FLAGS} -I/usr/local/include -Wall")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
endif()
I'm trying to run travis test,but I get the following error.
I checked my files and directories, all files are exist.
I think my mistake in cmake file, but I can't find it.
Maybe someone can help me?
make[1]: *** No rule to make target CMakeFiles/test.dir/all', needed byCMakeFiles/Examples.dir/all'. Stop.
cmake_minimum_required(VERSION 2.8.7)
project(test)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
option(BUILD_TESTS "Build tests for webdavclient" ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tests/ /sources)
add_library(test STATIC ${CMAKE_CURRENT_SOURCE_DIR}/sources/client.cpp tests/main.cpp)
find_package(OpenSSL REQUIRED)
find_package(Boost REQUIRED)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(test ${Boost_LIBRARIES})
endif()
if(UNIX)
set(DEPENDS_LIBRARIES ${OPENSSL_LIBRARIES} ${CURL_LIBRARY} ${Boost_LIBRARIES})
elseif(MSVC)
set(DEPENDS_LIBRARIES ${OPENSSL_LIBRARIES} ${CURL_LIBRARY} ${Boost_LIBRARIES} ws2_32)
endif()
add_executable(Examples ${CMAKE_CURRENT_SOURCE_DIR}/examples/main.cpp)
target_link_libraries(Examples ${PROJECT_NAME} ${DEPENDS_LIBRARIES})
if(BUILD_TESTS)
enable_testing()
file(GLOB ${PROJECT_NAME}_TEST_SOURCES tests/*.cpp)
add_executable(init ${${PROJECT_NAME}_TEST_SOURCES})
target_link_libraries(init ${PROJECT_NAME} ${DEPENDS_LIBRARIES})
add_test(NAME init COMMAND init "-s" "-r" "compact" "--use-colour" "yes")
endif()
Command enable_testing() among other things creates target test. But you already have library target with the same name. This confuses CMake. For avoid this, rename library target.
Also, it is not recommended to have target name same as the project. So, rename project too.
I am trying to compile my game project using Clion IDE but I have a problem when porting allegro 5. I get this error:
main.cpp:2:10: fatal error: 'allegro/allegro.h' file not found
#include <allegro/allegro.h>
My CMakeLists is:
cmake_minimum_required(VERSION 3.5)
project(testAllegro)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(testAllegro ${SOURCE_FILES})
INCLUDE_DIRECTORIES( /usr/local/include )
LINK_DIRECTORIES( /usr/local/lib )
file(GLOB LIBRARIES "/usr/local/Cellar/allegro/5.2.1.1_1/lib/*.dylib")
message("LIBRARIES = ${LIBRARIES}")
TARGET_LINK_LIBRARIES(testAllegro ${LIBRARIES})
Just I want to ask how can I add external Library allegro to Clion?
when you install allegro using homebrew link
use this cmake to compile clion project
cmake_minimum_required(VERSION 3.5)
project(testAllegro)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(testAllegro ${SOURCE_FILES})
INCLUDE_DIRECTORIES( /usr/local/Cellar/allegro/5.2.1.1_1/include )
LINK_DIRECTORIES( /usr/local/Cellar/allegro/5.2.1.1_1/lib )
file(GLOB LIBRARIES "/usr/local/Cellar/allegro/5.2.1.1_1/lib/*.dylib")
message("LIBRARIES = ${LIBRARIES}")
TARGET_LINK_LIBRARIES(testAllegro ${LIBRARIES})