CMake and pkg-config

1

I have no experience creating files CMakeLists.txt to compile my project and I was trying to do one for the first time.

Originally, from the command line, I compiled the project in the following way:

g++ -Wall -std=c++11 src/main.cpp src/shootingStar.cpp $(pkg-config --libs --static allegro-static-5 allegro_image-static-5 allegro_primitives-static-5)

The CMakeLists.txt file that I created, however, does not quite work.

cmake_minimum_required(VERSION 2.6)

project(Test)

set(SRC_DIR "src")         # Source
set(INC_DIR "src/include") # Includes

include(FindPkgConfig)
pkg_check_modules(ALLEGRO REQUIRED allegro-static-5 allegro_image-static-5 allegro_primitives-static-5)

include_directories(${INC_DIR})
include_directories(${ALLEGRO_INCLUDE_DIRS})

set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ALLEGRO_CFLAGS}")

set(SOURCES

    ${SRC_DIR}/main.cpp
    ${SRC_DIR}/shootingStar.cpp

)

add_executable(${CMAKE_PROJECT_NAME} ${SOURCES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${ALLEGRO_LDFLAGS})

When executing the makefile generated by cmake , more than 200 undefined references appear (eg: /.../allegro5/src/opengl/ogl_lock.c:550: undefined reference to 'glLoadIdentity' ).

What is the correct way to use pkg-config in a cmake file? (In case that is the error).

Thank you.

    
asked by Ediolot 24.01.2017 в 20:29
source

0 answers