 diff --git a/CMakeLists.txt b/CMakeLists.txt
 new file mode 100644
-index 0000000..b6cf6bc
+index 0000000..c7bf4b7
 --- /dev/null
 +++ b/CMakeLists.txt
-@@ -0,0 +1,2 @@
+@@ -0,0 +1,4 @@
 +cmake_minimum_required(VERSION 3.0)
++project(glew)
++include(flags OPTIONAL)
 +add_subdirectory(build/cmake)
 diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt
-index 1563f9f..4e8927d 100644
+index 1563f9f..0636a9b 100644
 --- a/build/cmake/CMakeLists.txt
 +++ b/build/cmake/CMakeLists.txt
-@@ -5,12 +5,15 @@ endif ()
+@@ -2,15 +2,19 @@ if ( NOT DEFINED CMAKE_BUILD_TYPE )
+   set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" )
+ endif ()
+ 
++if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
  project (glew)
  
  cmake_minimum_required (VERSION 2.4)
-+include (flags OPTIONAL)
++endif()
  
  if (COMMAND cmake_policy)
    cmake_policy (SET CMP0003 NEW)

 target_link_libraries (glewmx ${GLEW_LIBRARIES})
 target_link_libraries (glewmx_s ${GLEW_LIBRARIES})
 
@@ -110,21 +121,24 @@ set (cflags "-DGLEW_MX")
 set (libname ${GLEW_LIB_NAME}mx)
 configure_file (${GLEW_DIR}/glew.pc.in ${GLEW_DIR}/glewmx.pc @ONLY)
 

 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -46,14 +58,14 @@ include_directories (${GLEW_DIR}/include)
 add_library (glew SHARED ${GLEW_DIR}/src/glew.c)
 set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX "${DLL_PREFIX}")
 add_library (glew_s STATIC ${GLEW_DIR}/src/glew.c)
