Work on Ubuntu 16
I used g++ main.cpp -lpq
command for compiler my small project. Now I use Clion and wanna do same what I do with g++
. But I can't add compiler flags in cmake file and get compile error.
cmake_minimum_required(VERSION 3.5.1)
project(day_g)
set(CMAKE_CXX_FLAGS "-lpq")
add_definitions(-lpq)
message("CMAKE_CXX_FLAGS is ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(day_g ${SOURCE_FILES})
Also I run only cmake file and get CMAKE_CXX_FLAGS
with -lpq flag.
CMAKE_CXX_FLAGS is -lpq
-- Configuring done
-- Generating done
How properly add compiler flags to cmake file?
-l
is for linker, not for compiler. This flag is used for link with libraries. CMake has special command target_link_libraries for that purpose. – Brookweedtarget_link_libraries(day_g pq)
and all works fine! Can you post you answer so I can mark as asnwer. – Dillion