Hello all, so I've been working with SFML and GLEW in MSVC 2010 and have had very few issues (despite using static libraries for both, which can be an issue). I'm able to compile and run and have no linking issues or anything. However, I have plenty of friends whom I'd like to play my game that use Linux exclusively (Macs also for that matter). So, I wanted to use CMake to allow me to compile on several different platforms. I followed along the articles written here (http://www.gamedev.net/page/resources/_/technical/general-programming/cross-platform-test-driven-development-environment-using-cmake-part-1-r2986). I put together a successful CMakeLists.txt and it gets through fine, finding my GLEW and SFML directories. However, I get GLEW linking errors when I try to compile. It compiles the game fine, but when it gets to linking it cannot get past this GLEW stuff. At first I just thought it was the GLEW in SFML conflicting with my GLEW, but no matter what order I put the libraries in, I have the same issue. I'm hoping that since I can compile with MSVC2010 .sln file, but not with this, it's just a configuration issue. Hopefully someone here with experience with these 3 systems can give me some advice. Here's my CMakeList.txt:
cmake_minimum_required(VERSION 2.6)
project(BattleMap)
include_directories(
"${PROJECT_BINARY_DIR}"
$ENV{GLM_ROOT}
$ENV{RAPIDXML_ROOT}
$ENV{GLEW_ROOT}/include
)
set(EXECUTABLE_NAME "BattleMap")
set(BattleMap_SRCS
battlemap.cpp
battlemap.h
bufferobject.cpp
bufferobject.h
camera.cpp
camera.h
globals.h
vertices.h
texture.cpp
texture.h
vao.cpp
vao.h
supertexture.cpp
supertexture.h
shaderprog.cpp
shaderprog.h
scene.cpp
scene.h
submapscene.cpp
submapscene.h
mapscene.cpp
mapscene.h
mousepointerscene.cpp
mousepointerscene.h
application.cpp
application.h
main.cpp
)
add_executable(${EXECUTABLE_NAME} ${BattleMap_SRCS})
IF (WIN32)
MESSAGE("IS Win32")
ELSE (WIN32)
MESSAGE("NOT Win32")
ENDIF (WIN32)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
IF (WIN32)
add_library(glew_static STATIC IMPORTED)
set_target_properties(glew_static PROPERTIES
IMPORTED_LOCATION $ENV{GLEW_ROOT}/lib/glew32s.lib)
target_link_libraries(${EXECUTABLE_NAME} glew_static)
ELSE (WIN32)
find_package(GLEW REQUIRED)
ENDIF (WIN32)
# Detect and add SFML
find_package(SFML 2.0 REQUIRED system window graphics)
#find_package(GLEW REQUIRED)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()
#if(GLEW_FOUND)
# MESSAGE("GLEW include path found!")
# include_directories(${GLEW_INCLUDE_PATH})
# target_link_libraries(${EXECUTABLE_NAME} ${GLEW_LIBRARY})
#endif()
# Install target
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)
Some of the GLEW stuff commented out is just me trying different orders for CMake. If more information would be helpful, I'm more than happy to provide it. Thanks ahead of time.