I didn't know how to title this, it's quite unaccurate. Anyway here is the question:
I want to create a CMake project in Visual Studio that has to use glfw. However, I don't want to use the precompiled binaries, I want to compile glfw along with my application using the CMakeLists.txt file.
Here's my CMake file:
# CMakeList.txt : CMake project for BasicMandelbrotAnimation, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
project(BasicMandelbrotAnimation)
# Set the main file to main.cpp
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup")
# Include our different directories
include_directories(include)
include_directories(source)
# Include all source files in source directory
file(GLOB SOURCE source/*)
# Compile GLFW
add_subdirectory(extlibs/GLFW)
# CMake GLFW Settings
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 source to this project's executable.
add_executable (${PROJECT_NAME} ${SOURCE})
target_link_libraries(${PROJECT_NAME} glfw)
find_package(OpenGL REQUIRED)
target_include_directories(${PROJECT_NAME} PUBLIC ${OPENGL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${OPENGL_gl_LIBRARY})
target_link_libraries(${PROJECT_NAME} ${OPENGL_glu_LIBRARY})
# TODO: Add tests and install targets if needed.
The error I get is "Cannot open include file: 'unistd.h': No such file or directory" which is bugging me out because this is a UNIX file so how can I adapt the files to compile in windows?
Thank you.
EDIT:
This questions seemed like a duplicate, but isn't really. unistd.h is only the first problem, let's have a look at the problematic file:
#ifndef _glfw3_x11_platform_h_
#define _glfw3_x11_platform_h_
#include <unistd.h>
#include <signal.h>
#include <stdint.h>
#include <dlfcn.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/Xcursor/Xcursor.h>
// The XRandR extension provides mode setting and gamma control
#include <X11/extensions/Xrandr.h>
// The Xkb extension provides improved keyboard support
#include <X11/XKBlib.h>
// The Xinerama extension provides legacy monitor indices
#include <X11/extensions/Xinerama.h>
#if defined(_GLFW_HAS_XF86VM)
// The Xf86VidMode extension provides fallback gamma control
#include <X11/extensions/xf86vmode.h>
#endif
Here it is, first of all, unistdh is missing, I replace it with what was proposed in another post, but now it's the others that are missing, specifically dlfcn.h and X11 files and I don't know how to fix that.
Thank you.
EDIT2:
Forget what's inside x11_platform.h. The problem is in this line:
target_link_libraries(${PROJECT_NAME} glfw)
when doing this, cmake need x11_platform.h, that does not exist on windows. Does someone know how to skip this file or link another way?
Thank you.