<commit_before>cmake_minimum_required(VERSION 2.8)

project(gamedev-articles)

include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)

set(GIT_ROOT ${PROJECT_SOURCE_DIR})
set(SRC_PATH ${GIT_ROOT}/src)
set(EXT_LIB_DIR ${GIT_ROOT}/lib)

set(EXECUTABLE_OUTPUT_PATH ${GIT_ROOT}/bin)
#set(LIBRARY_OUTPUT_PATH ${GIT_ROOT}/bin)

include_directories("${SRC_PATH}")

set(CMAKE_CXX_STANDARD 11)

# Specify the list of directories to search for cmake modules.
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if (APPLE)
  set(CMAKE_MACOSX_RPATH 1)
  add_definitions(-DAPPLE)
endif()


#option(BUILD_IOS "Build iOS projects" OFF)

option(USE_GLFW "Use GLFW" ON)
option(USE_GLEW "Use GLEW" ON)
option(USE_DEVIL "Use DevIL" ON)
option(USE_GLUT "Use GLUT" ON)
option(USE_SOIL "Use SOIL" OFF)
option(USE_ASSIMP "Use assimp" OFF)
option(USE_OPENEXR "Use OpenEXR" OFF)
option(USE_EASYLOGGINGPP "Use easyloggingpp" ON)
option(USE_FREETYPEGL "Use freetype gl" OFF)
# Optionally one could use G3LOG instead of easylogger but it slows down compilation
option(USE_G3LOG "Use G3LOG" OFF)

# ILUT needs GLUT on windows
if (WIN32 AND USE_DEVIL)
  set(USE_GLUT ON)
endif()

# default to release
if (NOT CMAKE_BUILD_TYPE)
  message("Setting build type to release by default")
  set(CMAKE_CONFIGURATION_TYPES "Release" CACHE STRING "" FORCE)
endif()

set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)

# GLFW
if (USE_GLFW)
  find_package(OpenGL REQUIRED)
  if (OPENGL_FOUND)
    include_directories(${OPENGL_INCLUDE_DIR})
  endif (OPENGL_FOUND)
  set(EXT_LIBS ${EXT_LIBS} ${OPENGL_gl_LIBRARY})
endif ()

if (USE_GLFW)
  set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  add_subdirectory(${EXT_LIB_DIR}/glfw)
  set(EXT_LIBS ${EXT_LIBS} glfw)
  set(GLFW_INCLUDE_DIR ${EXT_LIB_DIR}/glfw/include)
endif (USE_GLFW)

if (APPLE AND (NOT USE_GLEW))
  set(EXT_LIBS ${EXT_LIBS} "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo")
endif ()

if (USE_GLEW)
  if (NOT EXISTS ${GIT_ROOT}/lib_bin/glew-2.1.0.zip)
    execute_process(
        COMMAND wget --no-check-certificate -P ${GIT_ROOT}/lib_bin https://netcologne.dl.sourceforge.net/project/glew/glew/2.1.0/glew-2.1.0.zip
    )
  endif ()
  if (NOT EXISTS ${GIT_ROOT}/lib/glew-2.1.0)
    execute_process(
      COMMAND unzip ${GIT_ROOT}/lib_bin/glew-2.1.0.zip -d ${GIT_ROOT}/lib
    )
  endif()

  add_definitions(-DGLEW_STATIC)
  set(GLEW_USE_STATIC_LIBS ON)
  add_subdirectory(${EXT_LIB_DIR}/glew-2.1.0/build/cmake)
  set(EXT_LIBS ${EXT_LIBS} glew)
  include_directories(${EXT_LIB_DIR}/glew-2.1.0/include)

  set(GLEW_INCLUDE_PATH ${EXT_LIB_DIR}/glew-2.1.0/include)
  set(GLEW_LIBRARY glew)
endif (USE_GLEW)

# GLM
include_directories(${EXT_LIB_DIR}/glm)

# TODO
#if (WIN32 AND USE_GLUT)
#  set(FREEGLUT_BUILD_SHARED_LIBS OFF)
#  set(FREEGLUT_BUILD_STATIC_LIBS ON)
#  set(FREEGLUT_REPLACE_GLUT ON)
#  set(FREEGLUT_BUILD_DEMOS OFF)
#  add_subdirectory(${EXT_LIB_DIR}/freeglut)
#  include_directories(${GIT_ROOT}/freeglut/include)
#endif()

# DEVIL
if (USE_DEVIL)<commit_msg>Fix compile glew on windows<commit_after>cmake_minimum_required(VERSION 2.8)

project(gamedev-articles)

include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)

set(GIT_ROOT ${PROJECT_SOURCE_DIR})
set(SRC_PATH ${GIT_ROOT}/src)
set(EXT_LIB_DIR ${GIT_ROOT}/lib)

set(EXECUTABLE_OUTPUT_PATH ${GIT_ROOT}/bin)
#set(LIBRARY_OUTPUT_PATH ${GIT_ROOT}/bin)

include_directories("${SRC_PATH}")

set(CMAKE_CXX_STANDARD 11)

# Specify the list of directories to search for cmake modules.
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if (APPLE)
  set(CMAKE_MACOSX_RPATH 1)
  add_definitions(-DAPPLE)
endif()


#option(BUILD_IOS "Build iOS projects" OFF)

option(USE_GLFW "Use GLFW" ON)
option(USE_GLEW "Use GLEW" ON)
option(USE_DEVIL "Use DevIL" ON)
option(USE_GLUT "Use GLUT" ON)
option(USE_SOIL "Use SOIL" OFF)
option(USE_ASSIMP "Use assimp" OFF)
option(USE_OPENEXR "Use OpenEXR" OFF)
option(USE_EASYLOGGINGPP "Use easyloggingpp" ON)
option(USE_FREETYPEGL "Use freetype gl" OFF)
# Optionally one could use G3LOG instead of easylogger but it slows down compilation
option(USE_G3LOG "Use G3LOG" OFF)

# ILUT needs GLUT on windows
if (WIN32 AND USE_DEVIL)
  set(USE_GLUT ON)
endif()

# default to release
if (NOT CMAKE_BUILD_TYPE)
  message("Setting build type to release by default")
  set(CMAKE_CONFIGURATION_TYPES "Release" CACHE STRING "" FORCE)
endif()

set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)

# GLFW
if (USE_GLFW)
  find_package(OpenGL REQUIRED)
  if (OPENGL_FOUND)
    include_directories(${OPENGL_INCLUDE_DIR})
  endif (OPENGL_FOUND)
  set(EXT_LIBS ${EXT_LIBS} ${OPENGL_gl_LIBRARY})
endif ()

if (USE_GLFW)
  set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  add_subdirectory(${EXT_LIB_DIR}/glfw)
  set(EXT_LIBS ${EXT_LIBS} glfw)
  set(GLFW_INCLUDE_DIR ${EXT_LIB_DIR}/glfw/include)
endif (USE_GLFW)

if (APPLE AND (NOT USE_GLEW))
  set(EXT_LIBS ${EXT_LIBS} "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo")
endif ()

if (USE_GLEW)
  if (NOT EXISTS ${GIT_ROOT}/lib_bin/glew-2.1.0.zip)
    execute_process(
        COMMAND wget --no-check-certificate -P ${GIT_ROOT}/lib_bin https://netcologne.dl.sourceforge.net/project/glew/glew/2.1.0/glew-2.1.0.zip
    )
  endif ()
  if (NOT EXISTS ${GIT_ROOT}/lib/glew-2.1.0)
    execute_process(
      COMMAND unzip ${GIT_ROOT}/lib_bin/glew-2.1.0.zip -d ${GIT_ROOT}/lib
    )
  endif()

  add_definitions(-DGLEW_STATIC)
  set(GLEW_USE_STATIC_LIBS ON CACHE BOOL "" FORCE)
  set(BUILD_UTILS OFF CACHE BOOL "" FORCE)
  add_subdirectory(${EXT_LIB_DIR}/glew-2.1.0/build/cmake)
  include_directories(${EXT_LIB_DIR}/glew-2.1.0/include)

  set(GLEW_INCLUDE_PATH ${EXT_LIB_DIR}/glew-2.1.0/include)
  
  if (WIN32)
    set (GLEW_LIB_NAME libglew32)
	link_directories(${CMAKE_CURRENT_BINARY_DIR}/lib/Release)
  else ()
    set (GLEW_LIB_NAME glew)
  endif()
  
  set(GLEW_glew_LIBRARY ${GLEW_LIB_NAME})
  set(EXT_LIBS ${EXT_LIBS} ${GLEW_LIB_NAME})
endif (USE_GLEW)

# GLM
include_directories(${EXT_LIB_DIR}/glm)

# Use glut on win32 / some libraries want glut
if (WIN32 AND USE_GLUT)
  set(FREEGLUT_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
  set(FREEGLUT_BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
  set(FREEGLUT_REPLACE_GLUT ON CACHE BOOL "" FORCE)
  set(FREEGLUT_BUILD_DEMOS  OFF CACHE BOOL "" FORCE)
  add_subdirectory(${EXT_LIB_DIR}/freeglut)
  include_directories(${GIT_ROOT}/freeglut/include)
  set(GLUT_glut_LIBRARY freeglut_static)
  set(GLUT_INCLUDE_DIR ${GIT_ROOT}/freeglut/include)
endif()

# DEVIL
if (USE_DEVIL)
{'fraction_non_alphanumeric': 0.11952962191128312, 'fraction_numerical': 0.011908306043465317, 'mean_word_length': 5.5615234375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6908255', 'n_tokens_mistral': 2903, 'n_tokens_neox': 2768, 'n_words': 539}