Skip to content

Commit 2afebef

Browse files
committed
simplify CMakeLists.txt (no more submodules and no api file generation)
1 parent c2d351a commit 2afebef

File tree

9 files changed

+75
-42
lines changed

9 files changed

+75
-42
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "library/vendor/stb"]
2-
path = library/vendor/stb
3-
url = https://github.com/nothings/stb.git
41
[submodule "tests/googletest"]
52
path = tests/googletest
63
url = https://github.com/google/googletest.git

CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if(UNIX)
3232
option(GF_DEV_ENABLE_ASAN "Enable Address Sanitizer" OFF)
3333
endif()
3434

35-
set(GF_SHARED ${BUILD_SHARED_LIBS})
35+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3636

3737
include(GNUInstallDirs)
3838
set(GF_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
@@ -43,20 +43,11 @@ find_package(SDL2 REQUIRED)
4343
find_package(Boost REQUIRED)
4444
find_package(Freetype REQUIRED)
4545
find_package(pugixml REQUIRED)
46+
find_package(Stb REQUIRED)
4647
find_package(ZLIB REQUIRED)
4748

4849
find_package(Threads REQUIRED)
4950

50-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
51-
52-
if(GF_USE_EMBEDDED_LIBS)
53-
message(STATUS "Build with embedded libraries")
54-
set(Stb_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/library/vendor/stb")
55-
else()
56-
# works on vcpkg
57-
find_package(Stb REQUIRED)
58-
endif()
59-
6051
if(APPLE)
6152
# on macos, always use OpenGL 3.3
6253
set(GF_BUILD_WITH_OPENGL3 ON)

cmake/FindStb.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
2222
include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake)
2323

2424
if(NOT Stb_INCLUDE_DIR)
25-
find_path(Stb_INCLUDE_DIR NAMES stb_image.h PATHS ${Stb_DIR} PATH_SUFFIXES include)
25+
find_path(Stb_INCLUDE_DIR NAMES stb_image.h PATHS ${Stb_DIR} PATH_SUFFIXES include include/stb)
2626
endif()
2727

2828
find_package_handle_standard_args(Stb DEFAULT_MSG Stb_INCLUDE_DIR)

include/gf/CoreApi.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Zlib
2+
// Copyright (c) 2023-2025 Julien Bernard
3+
#ifndef GF_CORE_API_H
4+
#define GF_CORE_API_H
5+
6+
#include "Portability.h"
7+
8+
#ifndef GF_STATIC
9+
# ifdef GF_BUILD
10+
# define GF_CORE_API GF_EXPORT
11+
# else
12+
# define GF_CORE_API GF_IMPORT
13+
# endif
14+
#else
15+
# define GF_CORE_API
16+
#endif
17+
18+
#endif // GF_CORE_API_H

include/gf/GraphicsApi.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Zlib
2+
// Copyright (c) 2023-2025 Julien Bernard
3+
#ifndef GF_GRAPHICS_API_H
4+
#define GF_GRAPHICS_API_H
5+
6+
#include "Portability.h"
7+
8+
#ifndef GF_STATIC
9+
# ifdef GF_BUILD
10+
# define GF_GRAPHICS_API GF_EXPORT
11+
# else
12+
# define GF_GRAPHICS_API GF_IMPORT
13+
# endif
14+
#else
15+
# define GF_GRAPHICS_API
16+
#endif
17+
18+
#endif // GF_GRAPHICS_API_H

include/gf/NetApi.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Zlib
2+
// Copyright (c) 2023-2025 Julien Bernard
3+
#ifndef GF_NET_API_H
4+
#define GF_NET_API_H
5+
6+
#include "Portability.h"
7+
8+
#ifndef GF_STATIC
9+
# ifdef GF_BUILD
10+
# define GF_NET_API GF_EXPORT
11+
# else
12+
# define GF_NET_API GF_IMPORT
13+
# endif
14+
#else
15+
# define GF_NET_API
16+
#endif
17+
18+
#endif // GF_NET_API_H

include/gf/Portability.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,22 @@
2727
#define GF_FORMAT(X, Y)
2828
#endif
2929

30+
#if defined _WIN32 || defined __CYGWIN__
31+
# ifdef __GNUC__
32+
# define GF_EXPORT __attribute__((dllexport))
33+
# define GF_IMPORT __attribute__((dllimport))
34+
# else
35+
# define GF_EXPORT __declspec(dllexport)
36+
# define GF_IMPORT __declspec(dllimport)
37+
# endif
38+
#else
39+
# if __GNUC__ >= 4
40+
# define GF_EXPORT __attribute__((visibility("default")))
41+
# define GF_IMPORT __attribute__((visibility("default")))
42+
# else
43+
# define GF_EXPORT
44+
# define GF_IMPORT
45+
# endif
46+
#endif
47+
3048
#endif // GF_PORTABILITY_H

library/CMakeLists.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,6 @@ add_library(gfnet0
160160
net/UdpSocket.cc
161161
)
162162

163-
generate_export_header(gfcore0
164-
BASE_NAME core
165-
EXPORT_MACRO_NAME CORE_API
166-
EXPORT_FILE_NAME CoreApi.h
167-
STATIC_DEFINE STATIC
168-
PREFIX_NAME GF_
169-
)
170-
171-
generate_export_header(gf0
172-
BASE_NAME graphics
173-
EXPORT_MACRO_NAME GRAPHICS_API
174-
EXPORT_FILE_NAME GraphicsApi.h
175-
STATIC_DEFINE STATIC
176-
PREFIX_NAME GF_
177-
)
178-
179-
generate_export_header(gfnet0
180-
BASE_NAME net
181-
EXPORT_MACRO_NAME NET_API
182-
EXPORT_FILE_NAME NetApi.h
183-
STATIC_DEFINE STATIC
184-
PREFIX_NAME GF_
185-
)
186-
187163
if (GF_BUILD_WITH_OPENGL3)
188164
target_compile_definitions(gf0
189165
PRIVATE GF_OPENGL3
@@ -254,7 +230,6 @@ target_include_directories(gfcore0
254230
target_include_directories(gf0
255231
PUBLIC
256232
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
257-
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
258233
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
259234
PRIVATE
260235
"${CMAKE_CURRENT_SOURCE_DIR}"
@@ -264,7 +239,6 @@ target_include_directories(gf0
264239
target_include_directories(gfnet0
265240
PUBLIC
266241
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
267-
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
268242
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
269243
PRIVATE
270244
"${CMAKE_CURRENT_SOURCE_DIR}/../include-priv"

library/vendor/stb

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)