I am trying to switch to CLion IDE in my Mac. My CMakeLists.txt works but while building the project, I get linker command failed error. I first tried with FindSDL2 and FindSDL2_IMAGE, but I removed it because I got the same error both with and without. I have a doubt about the SDL_LIBRARY and SDL2_IMAGE_LIBRARY, where it is declared?.
CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(OxEngine)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp engine.cpp sprite.cpp classes.h inventory.cpp vector.cpp)
MESSAGE(${SDL_INCLUDE_DIR} "  Image: " ${SDL2_IMAGE_INCLUDE_DIR})
include_directories(${SDL_INCLUDE_DIR})
include_directories(${SDL2_IMAGE_INCLUDE_DIR})
add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES})
MESSAGE(${SDL_LIBRARY} "  HH  " ${SDL2_IMAGE_LIBRARY})
target_link_libraries(${CMAKE_PROJECT_NAME} ${SDL_LIBRARY} ${SDL2_IMAGE_LIBRARY})
When loaded in CLion I get the following CMake output:
"/Applications/CLion 2.app/Contents/bin/cmake/mac/bin/cmake" -DCMAKE_BUILD_TYPE= -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -G "CodeBlocks - Unix Makefiles" /Users/nantha/Projc/my_projects/OxEngine/src
/Library/Frameworks/SDL2.framework/Headers  Image: /usr/local/include/SDL2
/usr/local/lib/libSDL.dylib-framework Cocoa  HH  /usr/local/lib/libSDL2_image.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/nantha/Projc/my_projects/OxEngine/src/cmake-build-runit
[Finished]
When I run the project I get
====================[ Build | OxEngine | Runit ]================================
"/Applications/CLion 2.app/Contents/bin/cmake/mac/bin/cmake" --build /Users/nantha/Projc/my_projects/OxEngine/src/cmake-build-runit --target OxEngine -- -lSDL2 -lSDL2_image
[ 16%] Linking CXX executable OxEngine
Undefined symbols for architecture x86_64:
  "_SDL_CreateRenderer", referenced from:
      Engine::init(Game&) in engine.cpp.o
  "_SDL_CreateTexture", referenced from:
      Inventory::render_itemButtons() in inventory.cpp.o
      Inventory::render_categoryButtons() in inventory.cpp.o
      Inventory::draw() in inventory.cpp.o
  "_SDL_CreateTextureFromSurface", referenced from:
      Engine::loadMedia() in engine.cpp.o
      Button::load_images() in engine.cpp.o
      Sprite::load_images() in sprite.cpp.o
      InventoryButton::load_icon() in inventory.cpp.o
  "_SDL_CreateWindow", referenced from:
      Engine::init(Game&) in engine.cpp.o
  "_SDL_DestroyRenderer", referenced from:
      Engine::close() in engine.cpp.o
  "_SDL_DestroyTexture", referenced from:
      Inventory::draw() in inventory.cpp.o
  "_SDL_DestroyWindow", referenced from:
      Engine::close() in engine.cpp.o
  "_SDL_QueryTexture", referenced from:
      Inventory::draw() in inventory.cpp.o
  "_SDL_RenderClear", referenced from:
      Engine::drawisoworld() in engine.cpp.o
  "_SDL_RenderCopy", referenced from:
      Engine::renderit(std::__1::vector<std::__1::vector<bool, std::__1::allocator<bool> >, std::__1::allocator<std::__1::vector<bool, std::__1::allocator<bool> > > >&, int, int, int) in engine.cpp.o
      Engine::draw_selected_tiles() in engine.cpp.o
      Button::drawButton() in engine.cpp.o
      Engine::drawisoworld() in engine.cpp.o
      InventoryButton::draw() in inventory.cpp.o
      Inventory::draw() in inventory.cpp.o
  "_SDL_RenderFillRect", referenced from:
      Inventory::render_itemButtons() in inventory.cpp.o
      Inventory::render_categoryButtons() in inventory.cpp.o
      Inventory::draw() in inventory.cpp.o
  "_SDL_RenderPresent", referenced from:
      Engine::update() in engine.cpp.o
  "_SDL_SetRenderDrawColor", referenced from:
      Engine::loadMedia() in engine.cpp.o
      Engine::drawisoworld() in engine.cpp.o
      Inventory::render_itemButtons() in inventory.cpp.o
      Inventory::render_categoryButtons() in inventory.cpp.o
      Inventory::draw() in inventory.cpp.o
  "_SDL_SetRenderTarget", referenced from:
      Inventory::render_itemButtons() in inventory.cpp.o
      Inventory::render_categoryButtons() in inventory.cpp.o
      Inventory::draw() in inventory.cpp.o
  "_SDL_SetTextureBlendMode", referenced from:
      Inventory::draw() in inventory.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [OxEngine] Error 1
make[2]: *** [CMakeFiles/OxEngine.dir/all] Error 2
make[1]: *** [CMakeFiles/OxEngine.dir/rule] Error 2
make: *** [OxEngine] Error 2
Project Structure:
Thank You
