0

This is my CMakeFIle.txt:

cmake_minimum_required(VERSION 3.16)
project (chippotto)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Debug)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
file(GLOB SOURCES "src/*.cpp")
add_executable(chippotto ${SOURCES})

find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
target_include_directories(chippotto PUBLIC "./include" ${SDL2_INCLUDE_DIRS})
target_link_libraries(chippotto ${SDL2_LINK_LIBRARY})
target_compile_options(chippotto PUBLIC ${SDL2_CFLAGS_OTHER})

I tried to include SDL as explained in this other StackOverflow answers (also checked this).

This is the output I get:

-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'sdl2'
--   Found sdl2, version 2.0.12
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ninazzo/repos/chippotto/build

and as it can be seen from the 4th-to-last line, SDL is found.

If then I try to run make in order to build the program, I get the following error:

/Users/ninazzo/repos/chippotto/./include/interpreterio.hpp:2:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>

and if I try to look for the word "SDL" in the generated makefile I find zero occurrences.

How can I make my program compile?

I could throw away CMake and use a makefile with pkg-config but I was looking for a more portable solution and I'd like to make it work with CMake.

I replaced `SDL2_INCLUDE_DIR` with `SDL2_INCLUDE_DIRS` as suggested in the comment section but the problem still remains.
Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
ninazzo
  • 547
  • 1
  • 6
  • 17

0 Answers0