# How to modify this CMakeLists.txt?

**URL:** <https://discourse.cmake.org/t/how-to-modify-this-cmakelists-txt/4707>\
**Category:** Code\
**Created:** [December 18, 2021, 3:52pm UTC](https://discourse.cmake.org/t/how-to-modify-this-cmakelists-txt/4707 "2021-12-18T15:52:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greendragon](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@greendragon](https://discourse.cmake.org/u/greendragon)\
**Post date:** [December 18, 2021, 3:52pm UTC](https://discourse.cmake.org/t/how-to-modify-this-cmakelists-txt/4707/1 "2021-12-18T15:52:39Z")

</div>

I have a C++ project on a Linux VM.  
The project runs fine in Visual C++ on my Win8.1. The project has pngs.  
On the VM cmake … and make work but the program stops when it has to render the pngs.  
This is the error I get:

SDL\_Surface\* loadedSurface = IMG\_Load(path.c\_str());  
if (loadedSurface == NULL)  
{printf(“Unable to load image %s! SDL\_image Error: %s\n”, path.c\_str(), IMG\_GetError());}

And this is the CMakeLists I made:

**cmake\_minimum\_required(VERSION 3.7)**  
**set(CMAKE\_CXX\_STANDARD 17)**  
**set(CMAKE\_CXX\_STANDARD\_REQUIRED ON)**

**add\_definitions(-std=c++17)**

**set(CXX\_FLAGS “-Wall”)**  
**set(CMAKE\_CXX\_FLAGS, “${CXX\_FLAGS}”)**

**project(CrazyTown)**

**set(CMAKE\_MODULE\_PATH ${CMAKE\_MODULE\_PATH} “${CMAKE\_SOURCE\_DIR}/cmake/”)**

**find\_package(SDL2 REQUIRED)**  
**find\_package(SDL2\_image REQUIRED)**

**include\_directories(${SDL2\_INCLUDE\_DIRS} src)**  
**include\_directories(${SDL2\_IMAGE\_DIRS} src)**

**add\_executable(CrazyTown src/main.cpp src/game.cpp src/texture.cpp src/streets.cpp src/random.cpp src/car.cpp src/buttons.cpp src/house.cpp)**

**target\_link\_libraries(CrazyTown ${SDL2\_LIBRARIES} ${SDL2\_IMAGE\_LIBRARIES})**

I ran the following command:`sudo apt-get install libsdl2-image-dev`

I have a cmake folder that contains FindSDL2.cmake and FindSDL2\_image.cmake

There are some dll files that I should include.

Please tell me how I should proceed.  
Thanks.
