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
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: CMakeLists.txt +37-2Lines changed: 37 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,10 +3,45 @@ project(NEToolKit) |
3 | 3 |
|
4 | 4 | set(CMAKE_CXX_STANDARD 17) |
5 | 5 |
|
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("") |
7 | 38 |
|
8 | 39 | # library |
| 40 | +set(NETOOLKIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/NEToolKit/include) |
9 | 41 | add_subdirectory(NEToolKit) |
10 | 42 |
|
11 | 43 | # examples |
12 | | -add_subdirectory(NEToolKitExamples) |
| 44 | +if(NETKIT_EXAMPLES) |
| 45 | + add_subdirectory(NEToolKitExamples) |
| 46 | +endif() |
| 47 | + |
Collapse file
Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # Library |
2 | 2 |
|
| 3 | +include_directories(${NETOOLKIT_INCLUDE_DIR}) |
3 | 4 | file(GLOB_RECURSE SOURCE_FILES "src/*.cpp") |
4 | 5 | add_library(NEToolKit ${SOURCE_FILES}) |
Collapse file
Copy file name to clipboard +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # Examples |
2 | 2 |
|
| 3 | +include_directories(${NETOOLKIT_INCLUDE_DIR}) |
3 | 4 | file(GLOB_RECURSE SOURCE_FILES "src/*.cpp") |
4 | 5 | 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
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 number | Diff line number | Diff line change |
|---|
@@ -14,11 +14,15 @@ $ cd build |
14 | 14 | $ cmake .. |
15 | 15 | $ make |
16 | 16 | ``` |
17 | | - |
18 | 17 | And you're good to go. |
19 | 18 |
|
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 | +``` |
21 | 23 |
|
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 |
23 | 25 |
|
| 26 | +You can probably use the `CMakeLists.txt` file too, but I didn't tested it. |
24 | 27 | However, you can use the Visual Studio C++ 2017 project files. |
| 28 | + |
Collapse file
Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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
Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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
Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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
Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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) |