GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve CMakeLists.txt. · CBenoit/NEToolKit@90555a7

This repository was archived by the owner on Jul 1, 2021. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • CMakeLists.txt
  • NEToolKitExamples
    • CMakeLists.txt
  • NEToolKit
    • CMakeLists.txt
  • README.md
  • cmake
    • config.cmake
    • macros
      • clang-settings.cmake
      • gcc-settings.cmake
    • options.cmake
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CMakeLists.txt‎

Copy file name to clipboardExpand all lines: CMakeLists.txt
+37-2Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,45 @@ project(NEToolKit)
33

44
set(CMAKE_CXX_STANDARD 17)
55

6-
include_directories(NEToolKit/include)
6+
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
7+
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
8+
9+
# Enable release mode by default
10+
if(NOT CMAKE_BUILD_TYPE)
11+
set(CMAKE_BUILD_TYPE "Release")
12+
endif()
13+
14+
include(cmake/options.cmake)
15+
include(cmake/config.cmake)
16+
17+
if(CMAKE_COMPILER_IS_GNUCXX)
18+
include(cmake/macros/gcc-settings.cmake)
19+
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
20+
include(cmake/macros/clang-settings.cmake)
21+
endif()
22+
23+
message("* ${PROJECT_NAME} build type : ${CMAKE_BUILD_TYPE}")
24+
25+
if(NETKIT_SHARED)
26+
message("* Build as shared library: Yes (default)")
27+
else()
28+
message("* Build as shared library: No (as static)")
29+
endif()
30+
31+
if(NETKIT_EXAMPLES)
32+
message("* Build examples : Yes")
33+
else()
34+
message("* Build examples : No (default)")
35+
endif()
36+
37+
message("")
738

839
# library
40+
set(NETOOLKIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/NEToolKit/include)
941
add_subdirectory(NEToolKit)
1042

1143
# examples
12-
add_subdirectory(NEToolKitExamples)
44+
if(NETKIT_EXAMPLES)
45+
add_subdirectory(NEToolKitExamples)
46+
endif()
47+
Collapse file

‎NEToolKit/CMakeLists.txt‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Library
22

3+
include_directories(${NETOOLKIT_INCLUDE_DIR})
34
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
45
add_library(NEToolKit ${SOURCE_FILES})
Collapse file

‎NEToolKitExamples/CMakeLists.txt‎

Copy file name to clipboard
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Examples
22

3+
include_directories(${NETOOLKIT_INCLUDE_DIR})
34
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
45
add_executable(NEToolKitExamples ${SOURCE_FILES})
5-
target_link_libraries(NEToolKitExamples ${PROJECT_BINARY_DIR}/NEToolKit/libNEToolKit.a)
6+
target_link_libraries(NEToolKitExamples $<TARGET_FILE:NEToolKit>)
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+7-3Lines changed: 7 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ $ cd build
1414
$ cmake ..
1515
$ make
1616
```
17-
1817
And you're good to go.
1918

20-
## Building on Windows
19+
By default, the examples project is not build. If you want to build it, run cmake like so:
20+
```
21+
$ cmake .. -D"NETKIT_EXAMPLES=1"
22+
```
2123

22-
You can probably use the `CMakeLists.txt` file too, but I'm not yet sure it works perfectly on windows (more specifically for building the example project).
24+
## Building on Windows
2325

26+
You can probably use the `CMakeLists.txt` file too, but I didn't tested it.
2427
However, you can use the Visual Studio C++ 2017 project files.
28+
Collapse file

‎cmake/config.cmake‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
2+
set(OS_WINDOWS 1)
3+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
4+
set(OS_LINUX 1)
5+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
6+
set(OS_MACOSX 1)
7+
else()
8+
message(FATAL_ERROR "Unsupported operating system")
9+
endif()
10+
11+
if(NETKIT_SHARED)
12+
set(BUILD_SHARED_LIBS 1)
13+
endif()
Collapse file

‎cmake/macros/clang-settings.cmake‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
message(STATUS "Found CLang ")
2+
3+
if(MIRAI_WITH_WARNINGS)
4+
# TODO: check these warnings
5+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -pedantic-errors -Wall -Wextra -Wold-style-cast -Woverloaded-virtual -Wfloat-equal -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wshadow -Wredundant-decls -Winit-self -Wswitch-default -Wundef -Winline")
6+
message(STATUS "CLang: Enabled warnings")
7+
endif()
8+
9+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
10+
11+
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -s -Os")
12+
13+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -O2")
Collapse file

‎cmake/macros/gcc-settings.cmake‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
message(STATUS "Found GCC ${CMAKE_CXX_COMPILER_VERSION}")
2+
3+
if(NETKIT_WITH_WARNINGS)
4+
# TODO: check these warnings
5+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -pedantic-errors -Wall -Wextra -Wold-style-cast -Woverloaded-virtual -Wfloat-equal -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wshadow -Wredundant-decls -Wdouble-promotion -Winit-self -Wswitch-default -Wundef -Wlogical-op -Winline")
6+
message(STATUS "GCC: Enabled warnings")
7+
endif()
8+
9+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
10+
11+
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -s -Os")
12+
13+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -O2")
Collapse file

‎cmake/options.cmake‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
option(NETKIT_WITH_WARNINGS "Show all warnings during compilation" 1)
2+
option(NETKIT_SHARED "Build library as shared library" 1)
3+
option(NETKIT_EXAMPLES "Build examples" 0)

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.