I'm a newbie in CMake, i know there are many StackOverflow post asking this, but none of those posts helped me fix this error, this is what my workspace looked like
project
.vscode
build
include\SDL2
lib\SDL2_x64
src
CMakeLists.txt
main.cpp
CMakeLists.txt
CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(project VERSION 0.1.0)
include(CTest)
enable_testing()
add_subdirectory(src)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
src/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
enable_testing()
add_executable(${CMAKE_PROJECT_NAME} main.cpp)
get_filename_component(PARENT_DIRECTORY ../ ABSOLUTE)
find_library(
SDL2_X64_LIB
PATHS "${PARENT_DIRECTORY}/lib"
)
find_path(
INCLUDE_DIR
PATHS "${PARENT_DIRECTORY}/include"
)
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC "${SDL2_X64_LIB}")
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC "${INCLUDE_DIR}")
# For debugging
message(STATUS "SDL2_LIB => ${SDL2_X64_LIB}")
message(STATUS "include_DIR => ${INCLUDE_DIR}")
I'm trying to add SDL2 include and library folder to CMake but it didn't find the file path
-- SDL2_LIB => SDL2_X64_LIB-NOTFOUND
-- include_DIR => INCLUDE_DIR-NOTFOUND
-- Configuring done
I tried putting the path into set()
but it still can't find SDL2/SDL.h
, I'm using the latest version of CMake