Skip to content

Commit 7b7b260

Browse files
authored
Merge pull request #6 from MoAlyousef/develop
Ongoing development
2 parents 00121c2 + 747bc8b commit 7b7b260

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+23901
-1039
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ BreakBeforeTernaryOperators: true
4242
BreakConstructorInitializersBeforeComma: false
4343
BreakConstructorInitializers: BeforeColon
4444
BreakStringLiterals: true
45-
ColumnLimit: 100
45+
ColumnLimit: 150
4646
CommentPragmas: '^ IWYU pragma:'
4747
CompactNamespaces: false
4848
ConstructorInitializerAllOnOneLineOrOnePerLine: false

.github/workflows/build.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ name: CMake
22

33
on: [push, pull_request]
44

5-
env:
6-
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
7-
BUILD_TYPE: Release
8-
95
jobs:
106
build:
117
runs-on: ${{ matrix.os }}
128
strategy:
9+
fail-fast: false
1310
matrix:
14-
os: [windows-latest, macos-10.15, ubuntu-18.04]
15-
11+
os: [windows-2016, windows-2019, macos-10.15, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
12+
env:
13+
BUILD_TYPE: Release
1614
steps:
17-
- uses: actions/checkout@v2
15+
- name: Checkout
16+
uses: actions/checkout@v2
1817
- name: Build
19-
run: cmake -S. -Bbin -DCMAKE_BUILD_TYPE=$BUILD_TYPE && cmake --build bin --parallel --config $BUILD_TYPE
18+
run: |
19+
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
20+
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel
21+
- name: Test
22+
run: |
23+
cd build/tests
24+
ctest -C ${{ env.BUILD_TYPE }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ compile_commands.json
55
temp.*
66
.vs
77
.cache
8-
build*/
8+
build*/
9+
.idea/
10+
cmake-build*/
11+
CMakeLists.txt.user

CMakeLists.txt

Lines changed: 101 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,125 @@
11
# This file was generated automatically by cmkr.
22

3-
# Regenerate CMakeLists.txt file when necessary
4-
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
3+
cmake_minimum_required(VERSION 2.8...3.8)
54

6-
if(CMKR_INCLUDE_RESULT)
7-
cmkr()
8-
endif()
9-
10-
cmake_minimum_required(VERSION 3.15)
11-
12-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
13-
14-
project(cmkr
15-
VERSION 0.1.4
16-
LANGUAGES C CXX
17-
DESCRIPTION "CMakeLists generator from TOML"
18-
)
19-
20-
include(FetchContent)
21-
22-
FetchContent_Declare(
23-
filesystem
24-
GIT_REPOSITORY https://github.com/gulrak/filesystem
25-
GIT_SHALLOW ON
26-
)
5+
# Regenerate CMakeLists.txt automatically in the root project
6+
set(CMKR_ROOT_PROJECT OFF)
7+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
8+
set(CMKR_ROOT_PROJECT ON)
279

28-
FetchContent_MakeAvailable(filesystem)
10+
# Bootstrap cmkr
11+
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
12+
if(CMKR_INCLUDE_RESULT)
13+
cmkr()
14+
endif()
2915

30-
FetchContent_Declare(
31-
mpark_variant
32-
URL https://github.com/mpark/variant/archive/v1.4.0.tar.gz
33-
)
16+
# Enable folder support
17+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
18+
endif()
3419

35-
FetchContent_MakeAvailable(mpark_variant)
20+
# Create a configure-time dependency on cmake.toml to improve IDE support
21+
if(CMKR_ROOT_PROJECT)
22+
configure_file(cmake.toml cmake.toml COPYONLY)
23+
endif()
3624

37-
FetchContent_Declare(
38-
toml11
39-
GIT_REPOSITORY https://github.com/ToruNiina/toml11
40-
GIT_SHALLOW ON
41-
)
25+
# Hack to hide a warning during cmkr bootstrapping on Windows
26+
if(CMAKE_BUILD_TYPE)
27+
endif()
4228

43-
FetchContent_MakeAvailable(toml11)
4429

45-
set(CMKRLIB_SOURCES
46-
src/cmake.cpp
47-
src/gen.cpp
48-
src/help.cpp
49-
src/build.cpp
50-
src/error.cpp
51-
)
30+
project(cmkr
31+
LANGUAGES
32+
CXX
33+
VERSION
34+
0.1.3
35+
DESCRIPTION
36+
"CMakeLists generator from TOML"
37+
)
38+
39+
# third_party
40+
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
41+
if(CMAKE_FOLDER)
42+
set(CMAKE_FOLDER "${CMAKE_FOLDER}/third_party")
43+
else()
44+
set(CMAKE_FOLDER third_party)
45+
endif()
46+
add_subdirectory(third_party)
47+
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
48+
49+
# tests
50+
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
51+
if(CMAKE_FOLDER)
52+
set(CMAKE_FOLDER "${CMAKE_FOLDER}/tests")
53+
else()
54+
set(CMAKE_FOLDER tests)
55+
endif()
56+
add_subdirectory(tests)
57+
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
58+
59+
60+
# Target cmkrlib
61+
set(cmkrlib_SOURCES
62+
"src/cmkrlib/args.cpp"
63+
"src/cmkrlib/build.cpp"
64+
"src/cmkrlib/cmake.cpp"
65+
"src/cmkrlib/error.cpp"
66+
"src/cmkrlib/gen.cpp"
67+
"src/cmkrlib/help.cpp"
68+
"src/cmkrlib/cmake.hpp"
69+
"src/cmkrlib/enum_helper.hpp"
70+
"src/cmkrlib/fs.hpp"
71+
"include/args.h"
72+
"include/build.h"
73+
"include/error.h"
74+
"include/gen.h"
75+
"include/help.h"
76+
"include/literals.h"
77+
cmake.toml
78+
)
79+
80+
add_library(cmkrlib STATIC ${cmkrlib_SOURCES})
81+
82+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${cmkrlib_SOURCES})
5283

53-
add_library(cmkrlib STATIC ${CMKRLIB_SOURCES})
84+
target_compile_features(cmkrlib PUBLIC
85+
cxx_std_11
86+
)
5487

5588
target_include_directories(cmkrlib PUBLIC
5689
include
57-
)
90+
)
5891

5992
target_link_libraries(cmkrlib PUBLIC
60-
toml11::toml11
93+
toml11
6194
ghc_filesystem
6295
mpark_variant
63-
)
96+
ordered_map
97+
)
6498

65-
target_compile_features(cmkrlib PUBLIC
66-
cxx_std_11
67-
)
99+
# Target cmkr
100+
set(cmkr_SOURCES
101+
"src/main.cpp"
102+
cmake.toml
103+
)
104+
105+
add_executable(cmkr ${cmkr_SOURCES})
68106

69-
set(CMKR_SOURCES
70-
src/main.cpp
71-
src/args.cpp
72-
)
107+
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
108+
if(NOT CMKR_VS_STARTUP_PROJECT)
109+
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT cmkr)
110+
endif()
73111

74-
add_executable(cmkr ${CMKR_SOURCES})
112+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${cmkr_SOURCES})
75113

76-
target_link_libraries(cmkr PUBLIC
114+
target_link_libraries(cmkr PRIVATE
77115
cmkrlib
78-
)
116+
)
79117

80118
install(
81-
TARGETS cmkr
82-
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
83-
COMPONENT cmkr
84-
)
85-
86-
87-
119+
TARGETS
120+
cmkr
121+
DESTINATION
122+
"${CMAKE_INSTALL_PREFIX}/bin"
123+
COMPONENT
124+
cmkr
125+
)

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ minimum = "3.15"
2222
name = "app"
2323
version = "0.1.0"
2424

25-
[[bin]]
25+
[[target]]
2626
name = "app"
27-
type = "exe"
27+
type = "executable"
2828
sources = ["src/main.cpp"]
2929
```
3030

@@ -43,19 +43,19 @@ toml11 = { git = "https://github.com/ToruNiina/toml11" }
4343
filesystem = { git = "https://github.com/gulrak/filesystem" }
4444
mpark_variant = { url = "https://github.com/mpark/variant/archive/v1.4.0.tar.gz" }
4545

46-
[[bin]]
46+
[[target]]
4747
name = "cmkrlib"
4848
type = "static"
4949
sources = ["src/cmake.cpp", "src/gen.cpp", "src/help.cpp", "src/build.cpp", "src/error.cpp"]
50-
include-dirs = ["include"]
51-
features = ["cxx_std_11"]
52-
link-libs = ["toml11::toml11", "ghc_filesystem"]
50+
include-directories = ["include"]
51+
compile-features = ["cxx_std_11"]
52+
link-libraries = ["toml11::toml11", "ghc_filesystem"]
5353

54-
[[bin]]
54+
[[target]]
5555
name = "cmkr"
56-
type = "exe"
56+
type = "executable"
5757
sources = ["src/main.cpp", "src/args.cpp"]
58-
link-libs = ["cmkrlib"]
58+
link-libraries = ["cmkrlib"]
5959

6060
[[install]]
6161
targets = ["cmkr"]
@@ -68,7 +68,7 @@ Currently supported fields:
6868
minimum = "3.15" # required
6969
description = "" # optional
7070
subdirs = [] # optional
71-
bin-dir = "bin" # optional
71+
build-dir = "build" # optional
7272
cpp-flags = [] # optional
7373
c-flags = [] # optional
7474
link-flags = [] # optional
@@ -97,15 +97,15 @@ toml11 = { git = "https://github.com/ToruNiina/toml11", tag = "v3.5.0" } # optio
9797
APP_BUILD_STUFF = false # optional
9898
APP_OTHER_STUFF = { comment = "does other stuff", value = false } # optional
9999

100-
[[bin]] # required, can define several binaries
100+
[[target]] # required, can define several binaries
101101
name = "app" # required
102-
type = "exe" # required (exe || lib || shared || static || interface)
102+
type = "executable" # required (executable || library || shared || static || interface)
103103
sources = ["src/*.cpp"] # required, supports globbing
104-
include-dirs = ["include"] # optional
104+
include-directories = ["include"] # optional
105105
alias = "" # optional
106-
features = [] # optional
107-
definitions = [] # optional
108-
link-libs = [] # optional
106+
compile-features = [] # optional
107+
compile-definitions = [] # optional
108+
link-libraries = [] # optional
109109
properties = { PROPERTY1 = "property1", ... } # optional
110110

111111
[[test]] # optional, can define several
@@ -125,13 +125,13 @@ The cmkr executable can be run from the command-line:
125125
```
126126
Usage: cmkr [arguments]
127127
arguments:
128-
init [exe|lib|shared|static|interface] Starts a new project in the same directory.
129-
gen Generates CMakeLists.txt file.
130-
build <extra cmake args> Run cmake and build.
131-
install Run cmake --install. Needs admin privileges.
132-
clean Clean the build directory.
133-
help Show help.
134-
version Current cmkr version.
128+
init [executable|library|shared|static|interface] Starts a new project in the same directory.
129+
gen Generates CMakeLists.txt file.
130+
build <extra cmake args> Run cmake and build.
131+
install Run cmake --install. Needs admin privileges.
132+
clean Clean the build directory.
133+
help Show help.
134+
version Current cmkr version.
135135
```
136136
The build command invokes cmake and the default build-system on your platform (unless a generator is specified), it also accepts extra cmake build arguments:
137137
```
@@ -140,20 +140,20 @@ cmkr build --config Release
140140

141141
## Binary types
142142

143-
### exe
144-
Executable binary.
143+
### executable
144+
Executable binary. Equivalent to [add_executable(name)](https://cmake.org/cmake/help/latest/command/add_executable.html).
145145

146-
### lib
147-
Library, can be static or shared depending on the BUILD_SHARED_LIBS variable.
146+
### library
147+
Library, can be static or shared depending on the BUILD_SHARED_LIBS variable. Equivalent to [add_library()](https://cmake.org/cmake/help/latest/command/add_library.html).
148148

149149
### static
150-
Static library/archive.
150+
Static library/archive. Equivalent to [add_library(name STATIC)](https://cmake.org/cmake/help/latest/command/add_library.html).
151151

152152
### shared
153-
Shared/dynamic library.
153+
Shared/dynamic library. Equivalent to [add_library(name SHARED)](https://cmake.org/cmake/help/latest/command/add_library.html).
154154

155155
### interface
156-
Header-only library.
156+
Header-only library. Equivalent to [add_library(name INTERFACE)](https://cmake.org/cmake/help/latest/command/add_library.html).
157157

158158
## Roadmap
159159
- Support more cmake fields.

0 commit comments

Comments
 (0)