Skip to content

Add CMake script - #492

Merged
gmaurel merged 2 commits into
uncrustify:masterfrom
jibsen:use-cmake
May 27, 2016
Merged

gmaurel merged 2 commits into
uncrustify:masterfrom
jibsen:use-cmake

Conversation

@jibsen

@jibsen jibsen commented May 22, 2016

Copy link
Copy Markdown
Contributor

As discussed in #470, this is an attempt to add a CMake script that works on both Windows and Linux, and can be used to create build files for Visual Studio.

Since tests/run_tests.py assumes the executable is in src, I added a hack that copies the executable there after build so the unit tests run. It might be preferable if the script took the executable path as an argument.

Example use on Linux:

mkdir build
cd build
cmake ..
make
make test

Example use on Windows with a Visual C++ command prompt:

mkdir build
cd build
cmake ..
cmake --build . --config Debug
ctest -C Debug

@jibsen

jibsen commented May 25, 2016

Copy link
Copy Markdown
Contributor Author

If you are interested in setting up AppVeyor CI to test Windows builds, an example config could be:

version: {build}

environment:
  matrix:
  - GENERATOR: MinGW Makefiles
  - GENERATOR: Visual Studio 14 2015
  - GENERATOR: Visual Studio 14 2015 Win64

configuration: Debug

before_build:
  # Workaround for CMake not wanting sh.exe on PATH for MinGW
  - set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
  - set PATH=C:\MinGW\bin;%PATH%
  - mkdir build
  - cd build
  - cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%GENERATOR%" ..

build_script: cmake --build . --config %CONFIGURATION%

test_script: ctest -V --interactive-debug-mode 0 --timeout 300 -C %CONFIGURATION%

This should build uncrustify and run the unit tests with VS 2015 32- and 64-bit, and MinGW (albeit a very old version).

@jibsen

jibsen commented May 25, 2016

Copy link
Copy Markdown
Contributor Author

The gitattributes file brings the number of failing tests on Windows down to 11:

Tests: ['c-sharp', 'c', 'cpp', 'd', 'java', 'pawn', 'objective-c', 'vala', 'ecma']
Processing c-sharp.test
Processing c.test
MISMATCH: 01016
MISMATCH: 01020
MISMATCH: 01036
MISMATCH: 01050
UNSTABLE: 02102
MISMATCH: 02501
MISMATCH: 02502
MISMATCH: 02503
Processing cpp.test
MISMATCH: 30091
UNSTABLE: 30265
UNSTABLE: 30815
MISMATCH: 30830
MISMATCH: 30831
MISMATCH: 30832
Processing d.test
Processing java.test
Processing pawn.test
Processing objective-c.test
UNSTABLE: 50007
Processing vala.test
Processing ecma.test
Passed 562 / 573 tests
Failed 11 test(s)

@jibsen

jibsen commented May 25, 2016

Copy link
Copy Markdown
Contributor Author

Added config folder which contains some header/footer files where line endings matter to gitattributes, down to 7 failing tests:

Processing c.test
MISMATCH: 01016
MISMATCH: 01036
MISMATCH: 01050
UNSTABLE: 02102
MISMATCH: 02501
MISMATCH: 02502
MISMATCH: 02503
Processing cpp.test
MISMATCH: 30091
UNSTABLE: 30265
UNSTABLE: 30815

jibsen added 2 commits May 25, 2016 18:35
This provides a way to generate build environments for Windows without
having to maintain Visual Studio project files for various versions.
Line endings of the test files matter, so we need to check them out
without conversion.
@jibsen

jibsen commented May 25, 2016

Copy link
Copy Markdown
Contributor Author

Fixed a bug in the generation of token_names.h, all tests pass here now.

@gmaurel
gmaurel merged commit b2e2301 into uncrustify:master May 27, 2016
@dirk-thomas

Copy link
Copy Markdown
Contributor

Thanks for creating the CMake file. It makes building it across platforms much easier.

Using the current code results in several compiler warnings for me (using Ubuntu Xenial, G++ 5.3.1). I created a PR to address those: #499

@dirk-thomas

Copy link
Copy Markdown
Contributor

Should the instructions in the README how to build this package be updated to use CMake? The Visual Studio project files could also be removed then.

@jibsen
jibsen deleted the use-cmake branch July 9, 2016 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants