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

CMakeLists.txt get_directory_property breaks contrib/cmake/msvc/cmakeBuild.cmd #371

Closed
clanmills opened this Issue Jun 26, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@clanmills
Collaborator

clanmills commented Jun 26, 2018

I have a weirdo issue that has 100% broken contrib/cmake/msvc/cmakeBuild.cmd

I don't understand the following line of code:

529 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2 $ nl -b a CMakeLists.txt | grep get_dir
   128	get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS)
530 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2 $

The workaround is to comment off line 128 and 129, although presumably that has consequences for building SAMPLES.

I've modified/commented around it as follows:

message("+++++++++++++++++++++++++++")
message("${CMAKE_SOURCE_DIR}/samples")
message("+++++++++++++++++++++++++++")

get_directory_property(SAMPLES DIRECTORY "${CMAKE_SOURCE_DIR}/samples" DEFINITION APPLICATIONS)
add_dependencies(tests exiv2lib exiv2 ${SAMPLES})

When I run this:

C:\Users\rmills\gnu\github\exiv2\exiv2\contrib\cmake\msvc>cmake --version | grep version
cmake version 3.10.3
C:\Users\rmills\gnu\github\exiv2\exiv2\contrib\cmake\msvc>cmd/c "vcvars 2017 64 && cmakeBuild --build"
...
-- Looking for inttypes.h - found
+++++++++++++++++++++++++++
C:/Users/rmills/gnu/github/exiv2/exiv2/samples
+++++++++++++++++++++++++++
CMake Error at CMakeLists.txt:132 (get_directory_property):
  get_directory_property DIRECTORY argument provided but requested directory
  not found.  This could be because the directory argument was invalid or, it
  is valid but has not been processed yet.
...
-- ------------------------------------------------------------------
-- Configuring incomplete, errors occurred!
See also "C:/Users/rmills/gnu/github/exiv2/exiv2/contrib/cmake/msvc/work_Release/exiv2/CMakeFiles/CMakeOutput.log".
See also "C:/Users/rmills/gnu/github/exiv2/exiv2/contrib/cmake/msvc/work_Release/exiv2/CMakeFiles/CMakeError.log".
"*** cmake errors in EXIV2 ***"
C:\Users\rmills\gnu\github\exiv2\exiv2\contrib\cmake\msvc>

When I build with conan:

C:\Users\rmills\gnu\github\exiv2\exiv2>rmdir/s/q build
C:\Users\rmills\gnu\github\exiv2\exiv2>mkdir build && cd build
C:\Users\rmills\gnu\github\exiv2\exiv2\build>conan install ..
PROJECT: Installing C:\Users\rmills\gnu\github\exiv2\exiv2\conanfile.py
Requirements
    Expat/2.2.5@pix4d/stable from 'conan-center'
...
PROJECT imports(): Copied 5 '.dll' files:
C:\Users\rmills\gnu\github\exiv2\exiv2\build>cmake ..
-- Building for: Visual Studio 15 2017
...
-- Looking for inttypes.h - found
-- sample: addmoddel
...
-- sample: remotetest
+++++++++++++++++++++++++++
C:/Users/rmills/gnu/github/exiv2/exiv2/samples
+++++++++++++++++++++++++++
-- Install prefix:    C:/Program Files (x86)/exiv2
-- ------------------------------------------------------------------
...
-- Build files have been written to: C:/Users/rmills/gnu/github/exiv2/exiv2/build
C:\Users\rmills\gnu\github\exiv2\exiv2\build>
...

So, the question is "What does DEFINITION APPLICATIONS mean"?

This is really strange. My message statements are pointing to the same directory. However, the output of the conan build reports -- sample: xxxx which are missing when cmake is executed from cmakeBuild.cmd

@clanmills

This comment has been minimized.

Collaborator

clanmills commented Jun 29, 2018

I think the code at CMakeLists.txt should be:

if( EXIV2_BUILD_SAMPLES )
    ##
    # tests
    add_custom_target(tests
        COMMAND env EXIV2_BUILDDIR="${CMAKE_BINARY_DIR}" make test
        WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test"
    )
    add_subdirectory( samples )
    get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS)
    add_dependencies(tests exiv2lib exiv2 ${SAMPLES})
endif()

Here's the git diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0df26204..cace079f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -111,23 +111,21 @@ if( EXIV2_BUILD_UNIT_TESTS )
 endif()
 
 if( EXIV2_BUILD_SAMPLES )
+    ##
+    # tests
+    add_custom_target(tests
+        COMMAND env EXIV2_BUILDDIR="${CMAKE_BINARY_DIR}" make test
+        WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test"
+    )
     add_subdirectory( samples )
+    get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS)
+    add_dependencies(tests exiv2lib exiv2 ${SAMPLES})
 endif()
 
 if( EXIV2_BUILD_PO )
     add_subdirectory( po )
 endif()
 
-##
-# tests
-add_custom_target(tests
-    COMMAND env EXIV2_BUILDDIR="${CMAKE_BINARY_DIR}" make test
-    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test"
-)
-
-get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS)
-add_dependencies(tests exiv2lib exiv2 ${SAMPLES})
-
 include(cmake/printSummary.cmake)
 
 # That's all Folks!

AndreasMartin72 added a commit to AndreasMartin72/exiv2 that referenced this issue Jul 3, 2018

piponazo added a commit that referenced this issue Jul 5, 2018

@piponazo piponazo closed this Jul 5, 2018

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