I recently updated my gtkmm framework to version 4.0.0 and updated code to be compatible with the framework. I'm using msys2 in JetBrains CLion on Windows. However when I'm compiling project I got wall of warnings and errors in various framework headers like gtkmm, glibmm etc. I can't find errors which could be related to my code. Here is my Cmake configurations
cmake_minimum_required (VERSION 3.17.5)
set (CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS " -lstdc++fs")
project (Accounter)
find_package(Boost 1.73 COMPONENTS date_time REQUIRED)
FIND_LIBRARY (LIBZIP_LIBRARY NAMES zip)
FIND_PATH (LIBZIP_INCLUDE_DIR zip.h PATH_SUFFIXES include/zip include ) # Find header
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE(PkgConfig REQUIRED)
pkg_check_modules(GTKMM gtkmm-4.0)
include_directories( ${GTKMM_INCLUDE_DIRS} )
link_directories( ${GTKMM_LIBRARY_DIRS} )
#ADD_DEFINITIONS(${GTK_CFLAGS_OTHER})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libzip DEFAULT_MSG LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR)
link_directories((Accounting))
add_subdirectory(Accounting)
link_directories(OdsFile)
add_subdirectory(OdsFile)
link_directories(GUI)
add_subdirectory(GUI)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(Accounter main.cpp)
target_link_libraries(Accounter LINK_PUBLIC Accounting OdsFile GUI ${Boost_LIBRARIES} ${LIBZIP_LIBRARY} stdc++fs ${GTKMM_LIBRARIES} )
else()
message( FATAL_ERROR "Boost library is required for this library")
ENDIF().
The compile log is under this link . Do I miss something in cmake configuration? How it should be compiled? I'll provide additional info, files if it will be required. I think errors should be on my side not on framework.
Related
I'm building a C++ program using CGAL, and I'm writing CMake install rules to deploy said program so that I can CPack the result and the end user doesn't have to install CGAL or any of its dependencies to use it. In order to do that, I need to include every shared library (DLLs on Windows etc) but I can't find a CMake variable that lets me do that. I searched around in the CGAL repo, but no luck. I tried using ${CGAL_LIBRARIES} but those don't give paths, and it doesn't seem like ${CGAL_LIBRARIES_DIRS} is a thing.
My current CMakeLists is based off the one generated by the dedicated CGAL script :
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.
project( MeshCleaner )
cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# Boost and its components
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
# include for local directory
include_directories( BEFORE include )
# include for local package
# Creating entries for target: meshCleaner
# ############################
add_executable( ${PROJECT_NAME} main.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${PROJECT_NAME} )
# Link the executable to CGAL and third-party libraries
target_link_libraries(${PROJECT_NAME} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
install(TARGETS ${PROJECT_NAME} DESTINATION . COMPONENT Libraries)
message(${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES})
if(WIN32)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
endif()
include(${PROJECT_NAME}CPack)
The simplest way to "fix" that issue is to use CGAL as header-only. Please check the manual. Here is the direct link to the installation manual of CGAL-4.14, section "Header-only with CMake Configuration".
I build llvm from git and want to use the libraries in a project, especially the libclang.
The "makefiles" are generated by means of CMake and for the LLVM part I found the setting LLVM_DIR to reroute the path for the llvm libraries, but for Clang I cannot find such a variable and I still see in my link line (it is a Cygwin system):
/usr/lib/libclang.dll.a /usr/lib/libclangTooling.dll.a.
Question: which environment variable do I set to get the right build Clang libraries?
The variable is Clang_DIR.
Just in case, I attach a minimalistic example of CMakeLists.txt file as well.
cmake_minimum_required(VERSION 3.12)
# Find CMake file for Clang
find_package(Clang REQUIRED)
# Add path to LLVM modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${LLVM_CMAKE_DIR}"
)
# import LLVM CMake functions
include(AddLLVM)
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${CLANG_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
add_definitions(${CLANG_DEFINITIONS})
add_llvm_executable(myTool main.cpp)
set_property(TARGET myTool PROPERTY CXX_STANDARD 11)
target_link_libraries(myTool PRIVATE clangTooling)
I am using Clion as IDE
I just updated my fedora from 24 to 25 in order to use C++17,
But unfortunately now, CLion (v 2017.2.3) display code error that wasn't there before the OS upgrade
Here an "error" shown using template argument as template for std::optional
Here an "error" shown using std::make_shared, saying I am using too many argument (I should need 2 apparently) while the actual constructor takes 3 argument. I remind that the code compile and works
My CMake file (dunno if it could help for this)
Cmake_minimum_required(VERSION 3.3)
project(FreeSouls CXX)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lprotobuf -lboost_timer -lboost_system -lboost_thread")
set(CMAKE_CXX_STANDARD 17)
if ( UNIX )
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra -Wno-deprecated-declarations")
message( STATUS Set Warnings flag : ${CMAKE_CXX_FLAGS})
endif()
enable_testing()
add_subdirectory( Protobuff )
include_directories(
cmake-build-debug/Protobuff
FySMQ/include/queue
FySMQ/include/bus
FySMemoryManager/include
Server/include/gateway
Server/include/network
Server/include/babble
Server/include/game Utils/src)
set(SOURCE_FILES_MM)
set(SOURCE_PROTOBUF
cmake-build-debug/Protobuff/FySBabbleMessage.pb.cc
cmake-build-debug/Protobuff/FySGtwMessage.pb.cc
cmake-build-debug/Protobuff/FySLoginMessage.pb.cc
cmake-build-debug/Protobuff/FySAuthenticationResponse.pb.cc
)
set(SOURCE_FILES_MQ
FySMQ/include/queue/LockFreeQueue.hh
FySMQ/include/queue/QueueContainer.hh
FySMQ/include/queue/LockingQueue.hh
FySMQ/include/bus/BusListener.hh
FySMQ/include/bus/FysBus.hh)
set(SOURCE_FILES_SRV
Server/src/gateway/Gateway.cpp
Server/include/gateway/Gateway.hh
Server/src/gateway/Context.cpp
Server/include/gateway/Context.hh
Server/src/network/SessionManager.cpp
Server/include/network/SessionManager.hh
Server/src/babble/Babble.cpp
Server/include/babble/Babble.hh
Server/src/babble/BabbleChannel.cpp
Server/include/babble/BabbleChannel.hh
Server/src/network/TcpConnection.cpp
Server/include/network/TcpConnection.hh
Server/src/gateway/GameServerInstance.cpp
Server/include/gateway/GameServerInstance.hh
Server/src/gateway/Authenticator.cpp
Server/include/gateway/Authenticator.hh
)
set(SOURCE_FILES_UTILS Utils/src/CheckVars.hh Utils/src/TokenGenerator.cpp Utils/src/TokenGenerator.hh)
set(SOURCE_FILES_ALL
${SOURCE_PROTOBUF}
${SOURCE_FILES_UTILS}
${SOURCE_FILES_MQ}
${SOURCE_FILES_MM}
${SOURCE_FILES_SRV})
set(SOURCE_FILES
${SOURCE_FILES_ALL}
Server/src/main.cpp)
set(SOURCE_FILES_TEST
${SOURCE_FILES_ALL}
FySMQ/test/TestUnitMQ.cpp
Utils/test/TestCheckVar.cpp
FySMQ/test/FysBusTest.hh)
### Server ###
add_executable(FreeSouls ${SOURCE_FILES})
target_link_libraries(FreeSouls proto )
# link against dynamic libraries
add_definitions(-DBOOST_ALL_DYN_LINK)
## Test executable
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
add_executable(UnitTests ${SOURCE_FILES_TEST})
target_link_libraries(UnitTests ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
add_test(UnitTests UnitTests)
Does this error ever happened to you? How can I fix that?
I found a post about a problem similar here
Linux CLion can't resolve namespace member
But it looked like it were a bug of the Clion and a new version fixed it,
knowing I was using the exact same version on fedora 24 and it was working fine before the upgrade, I don't know if it is the same.
As said by Chris, this was a bug from the CLion parser.
The release of the version 2017.3 has solved those issues.
I've wanted to use Clion for awhile but I've always had trouble with Cmake. Armed with Cygwin, I've almost gotten this stupid thing to work.
The issue is while I can compile a cmake file from within a cygwin terminal, in Clion I am told it cannot find the library I want.
Error:A required package was not found
The cmakelist.txt file
cmake_minimum_required(VERSION 3.3)
project(Test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PKG_CONFIG_PATH /usr/lib/pkgconfig)
set(PKG_CONFIG_EXECUTABLE /usr/bin/pkg-config.exe)
set(SOURCE_FILES main.cpp)
add_executable(Test ${SOURCE_FILES})
INCLUDE(FindPkgConfig)
pkg_check_modules(SDL2 REQUIRED "sdl2")
MESSAGE(STATUS "SDL library: " ${SDL2_LDFLAGS})
TARGET_LINK_LIBRARIES(Test ${SDL2_LDFLAGS})
I have no idea if setting the variables PKG_CONFIG_PATH and others work, but they successfully build a makefile for my use in cygwin that builds correctly.
I've deleted the cache, remade the project and everything. It just refuses to work in Clion
If I understood correctly, your cmake config is unable to find SDL library. I found it better to use find_package command instead of pkg_check_modules.
In order to find_package(SDL2) to work, there must be FindSDL2.cmake module in directory, specified by CMAKE_MODULE_PATH variable (usually, it is cmake/Modules directory inside your source tree).
FindSDL2.cmake is not a part of CMake, but you can find one online easily (check my own modules, for example: https://github.com/dragn/cmake-modules).
Refer to this doc for details: https://cmake.org/Wiki/CMake:How_To_Find_Libraries.
Put FindSDL2.cmake to cmake/Modules directory and add this to your CMakeLists.txt:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
...
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARY})
NOTE: Sadly, it appears that Leonardo has not succeeded in finding volunteers for maintaining FindSDL2.cmake in SDL community: https://cmake.org/Bug/view.php?id=14826.
I am trying to add xapian search engine library in cmake file
project(search)
cmake_minimum_required(VERSION 2.8)
find_package(Xapian REQUIRED)
aux_source_directory(. SRC_LIST)
target_link_libraries(${PROJECT_NAME}
${Xapian_LIBRARY}
)
add_executable(${PROJECT_NAME} ${SRC_LIST})
This is not working can any one tell me how to add this if i compile with -lxapian it works
Swap target_link_libraries() and add_executable() calls. You can link library only to already defined target.
And use ${XAPIAN_LIBRARIES} instead of ${Xapian_LIBRARY}.