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

cmake: Replaced CMAKE_CURRENT_SOURCE_DIR with CMAKE_SOURCE_DIR #174

Merged
merged 1 commit into from Oct 26, 2016

Conversation

Projects
None yet
2 participants
@masnagam
Contributor

masnagam commented Oct 26, 2016

cr_add_subproejct didn't work correctly when Criterion was used as a git submoudle in another project as follows.

$ cd my_git_project
$ mkdir vendor
$ git submodule add \
    https://github.com/Snaipe/Criterion.git vendor/criterion

You can reproduce the problem by running a script.

When you run the script, you can see the following error messages:

$ mkdir test
$ sh reproduce.sh test
...
CMake Error at /usr/share/cmake-3.5/Modules/ExternalProject.cmake:1915 (message):
  No download info given for 'csptr' and its source directory:

   /path/to/root/source/dependencies/libcsptr

  is not an existing non-empty directory.  Please specify one of:

   * SOURCE_DIR with an existing non-empty directory
   * URL
   * GIT_REPOSITORY
   * HG_REPOSITORY
   * CVS_REPOSITORY and CVS_MODULE
   * SVN_REVISION
   * DOWNLOAD_COMMAND
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/ExternalProject.cmake:2459 (_ep_add_download_command)
  vendor/criterion/.cmake/Modules/Subprojects.cmake:74 (externalproject_add)
  vendor/criterion/CMakeLists.txt:34 (cr_add_subproject)
...

I used CMake 3.5.1 on Xubuntu 16.04 for reproduction of the problem. You can probably reproduce the problem in other environments.

The cause of the problem was the use of CMAKE_SOURCE_DIR. CMAKE_SOURCE_DIR was expanded to the path to the top level of the source tree.

Due to the use of CMAKE_SOURCE_DIR, two dependencies folders are created.

The first one is created in the root source directory by CMake and doesn't contains source files of submodules. The other is created in vendor/criterion by git-submodule command and contains source files of submodules.

As a result, CMake reports the above error messages.

The problem was fixed by replacing CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR which was expanded to the path to the source directory currently being processed.

By this patch, only onedependencies folder is created in CMAKE_SOURCE_DIR, and the folder contains source files of submodules.

cmake: Replaced CMAKE_CURRENT_SOURCE_DIR with CMAKE_SOURCE_DIR
cr_add_subproejct didn't work correctly when Criterion was used as a git
submoudle in another project as follows.

    $ cd my_git_project
    $ mkdir vendor
    $ git submodule add \
        https://github.com/Snaipe/Criterion.git vendor/criterion

The cause of the problem was the use of CMAKE_SOURCE_DIR.
CMAKE_SOURCE_DIR was expanded to the path to the top level of the source
tree.

The problem was fixed by replacing CMAKE_SOURCE_DIR with
CMAKE_CURRENT_SOURCE_DIR which was expanded to the path to the source
directory currently being processed.
@Snaipe

Snaipe approved these changes Oct 26, 2016

LGTM. Thanks for your contribution!

@Snaipe Snaipe merged commit f29eaaa into Snaipe:bleeding Oct 26, 2016

1 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

Snaipe added a commit that referenced this pull request Feb 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment