Skip to content

Adds CMake support #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
*.sln
*.exe
*.txt
!CMakeLists.txt
*.db-shm
*.db-wal
*.opendb
*.vsidx
*.lock
.editorconfig
/build
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
project(cppfront)
cmake_minimum_required(VERSION 3.20)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(cppfront source/cppfront.cpp)

# The test scripts are generated in two steps - configure to replace the
# variables, - geneated the configured output to replace the generator
# expressions.
configure_file(regression-tests/run-tests.bat.in
${CMAKE_BINARY_DIR}/run-tests.bat.in @ONLY)

file(
GENERATE
OUTPUT run-tests.bat
INPUT ${CMAKE_BINARY_DIR}/run-tests.bat.in)

configure_file(regression-tests/run-tests.sh.in
${CMAKE_BINARY_DIR}/run-tests.sh.in @ONLY)

file(
GENERATE
OUTPUT run-tests.sh
INPUT ${CMAKE_BINARY_DIR}/run-tests.sh.in
FILE_PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_WRITE
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE)
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ Cppfront builds with any major C++20 compiler.

clang++-12 cppfront.cpp -std=c++20 -o cppfront

### CMake support

Alternatively the code can be build using CMake. The build directory will contain the regression test scripts.

## How do I build my `.cpp2` file?

Run `cppfront your.cpp2`, then run the generated `your.cpp` through any major C++20 compiler after putting `/cppfront/include` in the path so it can find `cpp2util.h`.
Expand Down
17 changes: 17 additions & 0 deletions regression-tests/run-tests.bat.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off
copy @CMAKE_SOURCE_DIR@\*.cpp2 .
set count=0
for %%f in (mixed-*.cpp2) do (
echo Starting cppfront.exe %%f
$<TARGET_FILE:cppfront> %%f > %%f.output 2>&1
del %%f
set /a count+=1
)
for %%f in (pure2-*.cpp2) do (
echo Starting cppfront.exe %%f -p
$<TARGET_FILE:cppfront> %%f -p > %%f.output 2>&1
del %%f
set /a count+=1
)
echo Done: %count% tests

23 changes: 23 additions & 0 deletions regression-tests/run-tests.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

set -e

cp @CMAKE_SOURCE_DIR@/regression-tests/*.cpp2 .
count=0

for f in mixed-*.cpp2
do
echo Starting cppfront $f
$<TARGET_FILE:cppfront> $f > $f.output 2>&1
rm $f
count=$((count+1))
done

for f in pure2-*.cpp2
do
echo Starting cppfront $f -p
$<TARGET_FILE:cppfront> $f -p > $f.output 2>&1
rm $f
count=$((count+1))
done
echo Done: $count tests