Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix cmake installation failed (Fix #13578) #14692

Merged
merged 1 commit into from
May 2, 2019
Merged

Fix cmake installation failed (Fix #13578) #14692

merged 1 commit into from
May 2, 2019

Conversation

sl1pkn07
Copy link
Contributor

@sl1pkn07 sl1pkn07 commented Apr 13, 2019

Description

fix installation when use cmake

#13578

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http:https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Copy link
Contributor

@larroy larroy left a comment

Choose a reason for hiding this comment

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

LGTM, tested locally and works.

Copy link
Contributor

@larroy larroy left a comment

Choose a reason for hiding this comment

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

The change looks good, but we are installing some garbage that I don't think should go on the install directory:

-- Installing: /usr/local/lib/cmake/dmlc/DMLCTargets.cmake
-- Installing: /usr/local/lib/cmake/dmlc/DMLCTargets-debug.cmake

...
-- Installing: /usr/local/./doc
-- Installing: /usr/local/./doc/index.md
-- Installing: /usr/local/./doc/conf.py
-- Installing: /usr/local/./doc/parameter.md
-- Installing: /usr/local/./doc/sphinx_util.py
-- Installing: /usr/local/./doc/Doxyfile
-- Installing: /usr/local/./doc/README
-- Installing: /usr/local/./doc/Makefile
-- Installing: /usr/local/./doc/.gitignore
-- Installing: /usr/local/./doc/build.md
-- Installing: /usr/local/lib/cmake/dmlc/dmlc-config.cmake
-- Installing: /usr/local/lib/cmake/dmlc/dmlc-config-version.cmake

Can we get rid of that?

@sl1pkn07
Copy link
Contributor Author

sl1pkn07 commented Apr 22, 2019

super ugly quick workground

# Not install dmlc-core docs in /
  sed '/doc/s/^/#/g' \
    -i 3rdparty/dmlc-core/CMakeLists.txt \
    -i 3rdparty/tvm/3rdparty/dmlc-core/CMakeLists.txt

but this sould be fixed in upstream

see https://github.com/dmlc/dmlc-core/blob/master/CMakeLists.txt#L216

the https://github.com/dmlc/dmlc-core/blob/master/CMakeLists.txt#L215 also sould be fixed, but is less problematic because is installed in the "correct" path ($prefix/./include = $prefix/include)

the latest one seems redundant because https://github.com/dmlc/dmlc-core/blob/master/CMakeLists.txt#L195-L201, but the option INSTALL_INCLUDE_DIR seems is not exposed in cmake-gui

in resume:

https://github.com/dmlc/dmlc-core/blob/master/CMakeLists.txt#L216 i think, should be configurable by option or use ${CMAKE_INSTALL_DATADIR} for install in $prefix/shared/doc
https://github.com/dmlc/dmlc-core/blob/master/CMakeLists.txt#L215 should be remove, move https://github.com/dmlc/dmlc-core/blob/master/CMakeLists.txt#L204 before https://github.com/dmlc/dmlc-core/blob/master/CMakeLists.txt#L195-L201 and simplify it like install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/dmlc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

ive try to make a PR with this changes in the dmlc-core, but idk when is merged/reviewed

greetings

something like:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91f42fc..84fc0a3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,7 @@ dmlccore_option(USE_S3 "Build with S3 support" OFF)
 dmlccore_option(USE_OPENMP "Build with OpenMP" ON)
 dmlccore_option(USE_CXX14_IF_AVAILABLE "Build with C++14 if the compiler supports it" OFF)
 dmlccore_option(GOOGLE_TEST "Build google tests" OFF)
+dmlccore_option(INSTALL_DOCUMENTATION "Install documentation" OFF)
 
 # include path
 set(INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include")
@@ -192,16 +193,12 @@ target_include_directories(dmlc PUBLIC
 target_compile_definitions(dmlc PRIVATE -D_XOPEN_SOURCE=700
   -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200809L -D_DARWIN_C_SOURCE)
 
+include(GNUInstallDirs)
 # ---[ Install Includes
-if(INSTALL_INCLUDE_DIR)
-  add_custom_command(TARGET dmlc POST_BUILD
-    COMMAND ${CMAKE_COMMAND} -E copy_directory
-    ${PROJECT_SOURCE_DIR}/include ${INSTALL_INCLUDE_DIR}/
-    )
-endif()
+install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/dmlc
+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 # ---[ Install the archive static lib and header files
-include(GNUInstallDirs)
 install(TARGETS dmlc
   EXPORT DMLCTargets
   ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -212,8 +209,10 @@ install(EXPORT DMLCTargets
   EXPORT_LINK_INTERFACE_LIBRARIES
   DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dmlc)
 
-install(DIRECTORY include DESTINATION .)
-install(DIRECTORY doc DESTINATION .)
+# ---[ Install documentation
+if(INSTALL_DOCUMENTATION)
+  install(DIRECTORY doc DESTINATION ${CMAKE_INSTALL_DATADIR})
+endif()
 
 # ---[ Package configurations
 include(CMakePackageConfigHelpers)

@sl1pkn07
Copy link
Contributor Author

pushed PR to upstream (dmlc/dmlc-core#528)

@larroy
Copy link
Contributor

larroy commented Apr 30, 2019

I tried both PRs together and I have errors:

-- Could NOT find Gperftools (missing: GPERFTOOLS_LIBRARIES GPERFTOOLS_INCLUDE_DIR)
-- Using JEMalloc malloc
--  OpenCV_LIBS=opencv_core;opencv_highgui;opencv_imgproc;opencv_imgcodecs;opencv_core;opencv_highgui;opencv_imgproc;opencv_imgcodecs
-- OpenCV 3.2.0 found (/usr/share/OpenCV)
USE_LAPACK is ON
CMake Error at 3rdparty/dmlc-core/3rdparty/googletest/googletest/cmake/internal_utils.cmake:149 (add_library):
  add_library cannot create target "gtest" because another target with the
  same name already exists.  The existing target is a static library created
  in source directory
  "/home/piotr/mxnet_cmake/3rdparty/googletest/googletest".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  3rdparty/dmlc-core/3rdparty/googletest/googletest/cmake/internal_utils.cmake:172 (cxx_library_with_type)
  3rdparty/dmlc-core/3rdparty/googletest/googletest/CMakeLists.txt:90 (cxx_library)


CMake Error at 3rdparty/dmlc-core/3rdparty/googletest/googletest/cmake/internal_utils.cmake:149 (add_library):
  add_library cannot create target "gtest_main" because another target with
  the same name already exists.  The existing target is a static library
  created in source directory
  "/home/piotr/mxnet_cmake/3rdparty/googletest/googletest".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  3rdparty/dmlc-core/3rdparty/googletest/googletest/cmake/internal_utils.cmake:172 (cxx_library_with_type)
  3rdparty/dmlc-core/3rdparty/googletest/googletest/CMakeLists.txt:91 (cxx_library)

@larroy
Copy link
Contributor

larroy commented Apr 30, 2019

LGTM, the issues listed are related to dmlc-core not to mxnet. I suggest we merge this and follow up on posterior PRs as it improves the current state.

@larroy
Copy link
Contributor

larroy commented Apr 30, 2019

@mxnet-label-bot update [build,cmake,pr-awaiting-merge]

@marcoabreu marcoabreu added CMake CMake related bugs/issues/improvements pr-awaiting-merge Review and CI is complete. Ready to Merge and removed pr-awaiting-review PR is waiting for code review labels Apr 30, 2019
@wkcn wkcn merged commit e17b7e2 into apache:master May 2, 2019
@wkcn
Copy link
Member

wkcn commented May 2, 2019

Merged. Thanks for your contribution!

access2rohit pushed a commit to access2rohit/incubator-mxnet that referenced this pull request May 14, 2019
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Build CMake CMake related bugs/issues/improvements pr-awaiting-merge Review and CI is complete. Ready to Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants