Skip to content
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

Improve CMakeLists #58

Merged
merged 1 commit into from
Nov 30, 2017
Merged

Improve CMakeLists #58

merged 1 commit into from
Nov 30, 2017

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented May 26, 2017

This PR adds the following changes:

  • add option BUILD_SHARED_LIBS allowing to build either the shared or the static library
  • follow best practice (aka Modern CMake), this will then allow to generate a LibYAMLConfig.cmake allowing other CMake project to build against this project
  • bump minimum required version from CMake 2.8 to CMake 3.0
  • in addition of building tests, it builds all examples
  • removed win32/config.h and configure a cmake/config.h file

I anticipate to add more improvements, with the goal of simplifying the building of PyYAML wheels.

@jcfr
Copy link
Contributor Author

jcfr commented May 26, 2017

Next step, integrate changes from #56

@jcfr
Copy link
Contributor Author

jcfr commented May 26, 2017

Question: What is the preferred CMake indent style ?

if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

or a space before the parenthesis

if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
  set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif ()

I started to standardize on the version without the extra space

@jcfr jcfr force-pushed the tweak-cmakelists branch 4 times, most recently from 2ab4966 to e57b0e5 Compare May 26, 2017 06:10
@jcfr
Copy link
Contributor Author

jcfr commented May 26, 2017

Cc: @jakirkham @ingydotnet

@jcfr
Copy link
Contributor Author

jcfr commented May 26, 2017

Associated email to yaml-core mailing list: https://sourceforge.net/p/yaml/mailman/message/35861496/

Copy link
Contributor

@sigmavirus24 sigmavirus24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also squash these down into one commit

.travis.yml Outdated
- clang
- gcc
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo pip install scikit-ci-addons==0.15.0; sudo ci_addons travis/install_cmake 3.2.0; fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we sudo pip installing scikit-ci-addons? This is going to make our builds incredibly slow (the use of sudo)

@jcfr
Copy link
Contributor Author

jcfr commented May 27, 2017

@sigmavirus24 Thanks for the review.

Please also squash these down into one commit

Will do.

using sudo ... to make our builds incredibly slow

Will update to avoid using sudo.

@jcfr jcfr force-pushed the tweak-cmakelists branch 2 times, most recently from c03278a to 994c9d4 Compare May 27, 2017 19:55
@jcfr
Copy link
Contributor Author

jcfr commented May 27, 2017

@sigmavirus24 Et voila. Commit squashed, use of sudo removed.

Thanks again for your help integrating these changes.

New build options
-----------------

* Add option BUILD_TESTING by default ON
See https://cmake.org/cmake/help/v2.8.12/cmake.html#module:CTest

* Simplify library type selection using standard option BUILD_SHARED_LIBS
See https://cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html

yamlConfig.cmake
----------------

* Generate and install yamlConfig.cmake, yamlConfigVersion.cmake and yamlTargets.cmake

* Bump CMake version and explicitly associate include dirs with targets
See https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#include-directories-and-usage-requirements

* Ensure building against libyaml using "find_package(yaml)" uses expected compile options: Set HAVE_CONFIG_H
as private compile option, YAML_DECLARE_STATIC as public

Testing
-------

* Build all examples from "tests" directory

CMake Best practices
--------------------

* configure "config.h" based on version info found in CMakeLists.txt

* Ensure buildsystem re-generation listing sources (best-practice)

It is not recommended to use GLOB to collect a list of source files from
the source tree. If no CMakeLists.txt file changes when a source is added
or removed then the generated build system cannot know when to ask CMake
to regenerate.

See https://cmake.org/cmake/help/v3.8/command/file.html

Compilation warnings
--------------------

* Set _CRT_SECURE_NO_WARNINGS if building using VisualStudio

This will avoid warnings like this one:

```
C:\projects\libyaml\tests\run-emitter.c(268): warning C4996: 'fopen':
This function or variable may be unsafe. Consider using fopen_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for
details.
```

Continuous Integration
----------------------

* travis: Install CMake >= 3.x using scikit-ci-addons

* Add comments to appveyor.yml and run-tests.sh
@jschueller
Copy link

jschueller commented Nov 28, 2017

ping @sigmavirus24, this should be good to go

@sigmavirus24 sigmavirus24 merged commit fe3d086 into yaml:master Nov 30, 2017
@jcfr
Copy link
Contributor Author

jcfr commented Nov 30, 2017

Thanks for integrating.

@jcfr jcfr deleted the tweak-cmakelists branch November 30, 2017 22:04
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