title: Include Conan Libraries with multiple cmake files/Program throws exception when calling glCreateShader only with conan libraries integrated
body: <p>I'm currently developing a small game native in C++ and OpenGL....</p>
  <p>So now I am at the point where I wanna include Nvidia PhysX to get the nice physics simulations. For that, I'm utilizing Conan (Without it, it's kinda annoying).</p>
  <p>The thing is when I imported everything in Clion correctly and cmake and c++ both recognize the libraries the program fails every time when calling the glCreateShader method from glad. And I don't know why? My guess is that I may be falsely included the libraries but I'm not really sure....</p>
  <p>The exception that is form is: Exception 0xc0000005 encountered at address 0x000000: User-mode data execution prevention (DEP) violation at location 0x00000000</p>
  <p>These are my cmake files:</p>
  <p><strong>Root cmake</strong></p>
  <pre><code>cmake_minimum_required(VERSION 3.18)
  project(code)
  
  set(CMAKE_CXX_STANDARD 17)
  
  add_subdirectory(externalCode/glad)
  add_subdirectory(externalCode/glfw)
  add_subdirectory(externalCode/glm)
  add_subdirectory(externalCode/assimp)
  add_subdirectory(externalCode/soloud)
  add_subdirectory(engine)
  add_subdirectory(game)
  </code></pre>
  <p><strong>Engine cmake</strong></p>
  <pre><code>cmake_minimum_required(VERSION 3.18)
  
  set(SOURCE_FILES src/main.cpp ../engine/src/GraphicsEngine/shader.cpp ../engine/include/engine/GraphicsEngine/shader.h ../engine/src/FileManager/FileManager.cpp ../engine/include/engine/FileManager/FileManager.h ../engine/src/GraphicsEngine/mesh.cpp ../engine/include/engine/GraphicsEngine/mesh.h ../engine/include/engine/GraphicsEngine/Components/Model.h ../engine/src/GraphicsEngine/GraphicsSystem.cpp ../engine/include/engine/GraphicsEngine/Scene.h ../engine/src/InputSystem/InputManager.cpp ../engine/include/engine/InputSystem/InputManager.h ../engine/src/GraphicsEngine/Utils/TransformUtils.cpp ../engine/include/engine/GraphicsEngine/Components/Transform.h ../engine/src/Tools/Grid.cpp ../engine/include/engine/Tools/Grid.h ../engine/src/Tools/CubicNode.cpp ../engine/include/engine/Tools/CubicNode.h ../engine/include/engine/Tools/Node.h src/ShipController.cpp src/ShipController.h)
  
  set(EXE_FILE Game)
  
  include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
  conan_basic_setup()
  
  add_executable(${EXE_FILE} ${SOURCE_FILES})
  
  target_compile_features(${EXE_FILE} PRIVATE cxx_std_17)
  
  target_link_libraries(${EXE_FILE} PRIVATE Engine)
  </code></pre>
  <p><strong>Game cmake</strong></p>
  <pre><code>cmake_minimum_required(VERSION 3.18)
  
  file(GLOB_RECURSE HEADER_LIST CONFIGURE_DEPENDS &quot;include/**.h&quot;)
  file(GLOB_RECURSE PRIVATE_HEADER_LIST CONFIGURE_DEPENDS &quot;src/**.h&quot;)
  file(GLOB_RECURSE SOURCE_LIST CONFIGURE_DEPENDS &quot;src/**.cpp&quot;)
  
  set(ENGINE_NAME Engine)
  
  include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
  conan_basic_setup()
  
  add_library(${ENGINE_NAME} ${HEADER_LIST} ${PRIVATE_HEADER_LIST} ${SOURCE_LIST})
  
  target_compile_features(${ENGINE_NAME} PRIVATE cxx_std_17)
  set_target_properties(${ENGINE_NAME} PROPERTIES LINKER_LANGUAGE CXX)
  
  target_link_libraries(${ENGINE_NAME} PUBLIC glfw glad glm assimp soloud ${CONAN_LIBS})
  
  target_include_directories(${ENGINE_NAME} PUBLIC include/)
  </code></pre>
  <p>So the project structure is as follows: I have one cmake file(the first) that adds all the libraries and the two separate projects. Also, I have one cmake file each for the &quot;engine&quot;(The more abstract parts) and a concrete game project where I set up everything and an actual executable is generated. Both of these projects include the Conan files because else I get an exception that it can't find the libraries.</p>
  <p>Last but not least this is the shader class that throws the exception:</p>
  <p><strong>shader.h</strong></p>
  <pre><code>#pragma once
  
  #include &quot;glm/mat4x4.hpp&quot;
  #include &quot;glm/vec4.hpp&quot;
  #include &quot;glm/vec3.hpp&quot;
  #include &quot;glad/glad.h&quot;
  #include &quot;glm/gtc/type_ptr.hpp&quot;
  
  #include &lt;filesystem&gt;
  #include &lt;string&gt;
  
  #include &quot;engine/FileManager/FileManager.h&quot;
  
  
  namespace gl3::engine::Graphics {
      class shader {
      public:
          shader(const std::filesystem::path &amp;vertexShaderAsset, const std::filesystem::path &amp;fragmentShaderAsset);
  
          // explicit move constructor
          shader(shader &amp;&amp;other) noexcept {
              std::swap(this-&gt;shaderProgram, other.shaderProgram);
              std::swap(this-&gt;vertexShader, other.vertexShader);
              std::swap(this-&gt;fragmentShader, other.fragmentShader);
          }
  
          void use() const;
  
          void setVector(const std::string &amp;uniform, glm::vec4 vector) const;
          void setVector3(const std::string &amp;uniform, glm::vec3 vector) const;
          void setMatrix(const std::string &amp;uniform, glm::mat4 matrix) const;
          void setBool(const std::string &amp;name, bool value) const;
          void setInt(const std::string &amp;name, int value) const;
          void setFloat(const std::string &amp;name, float value) const;
  
          ~shader();
  
      private:
          unsigned int shaderProgram = 0;
          unsigned int vertexShader = 0;
          unsigned int fragmentShader = 0;
      };
  }
  </code></pre>
  <p><strong>shader.cpp</strong></p>
  <pre><code>#pragma once
  
  #include &quot;engine/GraphicsEngine/shader.h&quot;
  
  
  namespace gl3::engine::Graphics {
  
      struct glStatusData {
          int success;
          const char* shaderName;
          char infoLog[GL_INFO_LOG_LENGTH];
      };
  
      unsigned int loadAndCompileShader(GLuint shaderType, const std::filesystem::path &amp;shaderAssetPath){
  
          auto shaderAsset = filesystem::FileManager::getAssetFileFrom(shaderAssetPath);
          const char* shaderSource = shaderAsset.c_str();
          unsigned int shader = glCreateShader(shaderType);
  
          glShaderSource(shader, 1, &amp;shaderSource, nullptr);
          glCompileShader(shader);
  
          {
              glStatusData compilationStatus{};
  
              if(shaderType == GL_VERTEX_SHADER) compilationStatus.shaderName = &quot;VertexShader&quot;;
              if(shaderType == GL_FRAGMENT_SHADER) compilationStatus.shaderName = &quot;FragmentShader&quot;;
  
              glGetShaderiv(shader, GL_COMPILE_STATUS, &amp;compilationStatus.success);
              if(compilationStatus.success == GL_FALSE){
                  glGetShaderInfoLog(shader, GL_INFO_LOG_LENGTH, nullptr, compilationStatus.infoLog);
                  throw std::runtime_error(&quot;ERROR::SHADER::&quot; + std::string(compilationStatus.shaderName)
                                                                      + &quot;::COMPILATION_FAILDE\n&quot;
                                                                      + std::string(compilationStatus.infoLog));
              }
          }
  
          return shader;
      }
  
      shader::shader(const std::filesystem::path &amp;vertexShaderAsset, const std::filesystem::path &amp;fragmentShaderAsset) {
  
          // Load and compile shader
          vertexShader = loadAndCompileShader(GL_VERTEX_SHADER, vertexShaderAsset);
          fragmentShader = loadAndCompileShader(GL_FRAGMENT_SHADER, fragmentShaderAsset);
  
          // Create a shader program, attach the shaders and link program
          shaderProgram = glCreateProgram();
          glAttachShader(shaderProgram, vertexShader);
          glAttachShader(shaderProgram, fragmentShader);
          glLinkProgram(shaderProgram);
  
          // Handle the errors and throw exceptions
          {
              glStatusData linkingStatus{};
              glGetProgramiv(shaderProgram, GL_LINK_STATUS, &amp;linkingStatus.success);
              if(linkingStatus.success == GL_FALSE){
                  glGetShaderInfoLog(shaderProgram, GL_INFO_LOG_LENGTH, nullptr, linkingStatus.infoLog);
                  throw std::runtime_error(&quot;ERROR::PROGRAM::LINKING_FAILED\n&quot; + std::string(linkingStatus.infoLog));
              }
          }
  
          // Detach the shaders
          glDetachShader(shaderProgram, vertexShader);
          glDetachShader(shaderProgram, fragmentShader);
          glDeleteShader(vertexShader);
          glDeleteShader(fragmentShader);
      }
  
      void shader::use() const {
          glUseProgram(shaderProgram);
      }
  
      void shader::setVector(const std::string &amp;uniform, glm::vec4 vector) const {
          unsigned int uniformLocation = glGetUniformLocation(shaderProgram, uniform.c_str());
          glUniform4f(uniformLocation, vector.x, vector.y, vector.z, vector.w);
      }
  
      void shader::setVector3(const std::string &amp;uniform, glm::vec3 vector) const {
          unsigned int uniformLocation = glGetUniformLocation(shaderProgram, uniform.c_str());
          glUniform3f(uniformLocation, vector.x, vector.y, vector.z);
      }
  
      void shader::setMatrix(const std::string &amp;uniform, glm::mat4 matrix) const {
          unsigned int uniformLocation = glGetUniformLocation(shaderProgram, uniform.c_str());
          glUniformMatrix4fv(uniformLocation, 1, GL_FALSE, glm::value_ptr(matrix));
      }
  
      shader::~shader() {
          glDeleteShader(vertexShader);
          glDeleteShader(fragmentShader);
          glDeleteShader(shaderProgram);
      }
  
      void shader::setBool(const std::string &amp;name, bool value) const {
          unsigned int uniformLocation = glGetUniformLocation(shaderProgram, name.c_str());
          glUniform1i(uniformLocation, (int) value);
      }
  
      void shader::setInt(const std::string &amp;name, int value) const {
          unsigned int uniformLocation = glGetUniformLocation(shaderProgram, name.c_str());
          glUniform1i(uniformLocation, (int) value);
      }
  
      void shader::setFloat(const std::string &amp;name, float value) const {
          unsigned int uniformLocation = glGetUniformLocation(shaderProgram, name.c_str());
          glUniform1f(uniformLocation, value);
      }
  }
  </code></pre>
  <p>Any help would be really appreciated. I honestly don't know where to even start.....</p>