我正在尝试使用Clion IDE编译我的游戏项目,但是在移植allegro 5时遇到问题。出现此错误:

main.cpp:2:10: fatal error: 'allegro/allegro.h' file not found
   #include <allegro/allegro.h>

我的CMakeLists是:
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})

我想问一下如何将外部库快板添加到Clion?

最佳答案

当您使用自制link安装Allegro时

使用此cmake编译clion项目

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})

09-18 20:59