I created a simple hello world program with cmake. I created a Toolchain file for mingw32. It compiled in linux and the mingw32 fine. I modified the program to use SDL. It compiled under linux but failed to work with mingw32. Is there a standard Toolchain file that make this work. Here is the Toolchain file:
Code:
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i686-pc-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i686-pc-mingw32-g++)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i686-pc-mingw32 )
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
(I also tried /usr/i686-pc-mingw32/sys-root/mingw/ as the root path.)
Here is the CMakeLists.txt file:
Code:
Find_Package(SDL REQUIRED)
if (NOT SDL_FOUND)
message(FATAL_ERROR "SDL not found!")
endif (NOT SDL_FOUND)
include_directories(include ${SDL_INCLUDE_DIR})
link_libraries(
${SDL_LIBRARY}
)
add_executable(hello hello.cpp)