[CMake] External dependencies and Windows

Michael Wild themiwi at gmail.com
Mon Feb 4 10:29:46 EST 2013


How did you compile SDL?

Most generally, you would do:

find_path(SDL2_INCLUDE_DIR SDL.h PATH_SUFFIXES SDL2)
# I have no idea against which libraries you have to link, so you might
need more than this
find_library(SDL2_LIBRARY SDL)

if(NOT SDL2_INCLUDE_DIR OR NOT SDL2_LIBRARY)
  message(SEND_ERROR "Failed to find SDL2")
endif()
include_directories(${SDL2_INCLUDE_DIR})
set(SDL2_LIBRARIES ${SDL2_LIBRARY}) # and possibly others


add_executable(sdl_test sdl_test.cpp)
target_link_libraries(sdl_test ${SDL_LIBRARIES})


Then, when you invoke CMake, you use the
-DCMAKE_PREFIX_PATH=/path/to/SDL/build flag to inform CMake about where to
search for headers and libraries.


On Mon, Feb 4, 2013 at 3:14 PM, Ansis Māliņš <ansis.malins at gmail.com> wrote:

> It looks like I'm still asking the wrong questions.
>
> As a last resort, here's my specific problem: I want to compile and run a
> hello world SDL2 application on Windows, Linux, and OS X - purely as an
> exercise in CMake. How would YOU do this?
>
> SDL2 only exists in source form in their repository.
>
> This is my main.cpp:
> #include <SDL.h>
> int main(int argc, char** argv)
> {
> if (SDL_Init(SDL_INIT_VIDEO) < 0) printf("FAILURE\n");
>  else printf("SUCCESS\n");
> SDL_Quit();
>  return 0;
> }
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130204/50fcc2c5/attachment.htm>


More information about the CMake mailing list