Skip to content

Commit 0ed6035

Browse files
committed
fix: we weren't linking the dependencies to library target also
1 parent 951df48 commit 0ed6035

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

app/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
message("-- Creating main executable with target name ${CMAKE_PROJECT_NAME}")
22
add_executable(${CMAKE_PROJECT_NAME} main.cpp)
33

4-
message(" finding where Skia shared library is")
5-
include(FindSkiaSystem)
6-
message(" set SKIA_LIBRARIES to ${SKIA_LIBRARIES}")
7-
84
message("-- Use target_link_directories to")
95
message(" tell target where to look for .dlls")
106
message(" (by default in CMake +3 it is recommended to link by targets, not directories)")

app/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main(int argc, char *argv[]) {
1111
std::cout << "- Hello!" << std::endl;
1212

1313
std::cout << "- Initializing GLFW library..." << std::endl;
14-
GLUtil::initializeGLFW();
14+
initializeGLFW();
1515

1616
std::cout << "- Create blank OpenGL Window" << std::endl;
1717
std::cout << " for GPU rendering" << std::endl;

buildscripts/ModuleSetup.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ macro(setup_module name)
22
set(MODULE_NAME ${name})
33
unset(MODULE_INCLUDES) # module's include paths
44
unset(MODULE_FILES) # module's files
5+
unset(MODULE_CUSTOM_DIRECTORIES) # custom directories where to look for .so or .a files (DLLs)
6+
unset(MODULE_LINK) # module's targets to link against to
57
endmacro()
68

79
macro(finish_module)
@@ -14,5 +16,15 @@ macro(finish_module)
1416
message(" with include directories ${MODULE_INCLUDES}")
1517
include_directories(PRIVATE ${MODULE_INCLUDES})
1618

19+
if (MODULE_CUSTOM_DIRECTORIES)
20+
target_link_directories(${MODULE_NAME} PRIVATE ${MODULE_CUSTOM_DIRECTORIES})
21+
message(" find libraries in directories ${MODULE_CUSTOM_DIRECTORIES}")
22+
endif()
23+
24+
if (MODULE_LINK)
25+
target_link_libraries(${MODULE_NAME} PRIVATE ${MODULE_LINK})
26+
message(" link with libraries ${MODULE_LINK}")
27+
endif()
28+
1729
endmacro()
1830

src/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,18 @@ set(MODULE_FILES
1313
${CMAKE_SOURCE_DIR}/src/ExampleCanvas.cpp
1414
)
1515

16+
message(" finding where Skia shared library is")
17+
include(FindSkiaSystem)
18+
message(" set SKIA_LIBRARIES to ${SKIA_LIBRARIES}")
19+
20+
set(LIBRARY_DEPENDENCIES
21+
${APP_DEPENDENCIES}
22+
${SKIA_LIBRARIES}
23+
glad
24+
)
25+
26+
set(MODULE_LINK ${LIBRARY_DEPENDENCIES})
27+
28+
set(MODULE_CUSTOM_DIRECTORIES ${CMAKE_BINARY_DIR}/src)
29+
1630
finish_module()

src/GLUtil.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// For using OpenGL
88
#include <GLFW/glfw3.h>
99

10-
using namespace GLUtil;
11-
1210
// GLFW is the library which we use to call OpenGL functions
1311
void initializeGLFW() {
1412
glfwInit();

src/GLUtil.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
#pragma once
66

7-
namespace GLUtil {
8-
97
void initializeGLFW();
108
bool loadGLFunctions();
119

12-
};

src/GLWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void GLWindow::createGLWindow() {
8080

8181
// Load GL functions AFTER setting the current context
8282
// Either we're getting a segmentation fault...
83-
GLUtil::loadGLFunctions();
83+
loadGLFunctions();
8484

8585
m_glfwWindow = window;
8686
};

0 commit comments

Comments
 (0)