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

CMake build misses some parameters #17943

Open
sa-mustafa opened this issue Mar 31, 2020 · 7 comments
Open

CMake build misses some parameters #17943

sa-mustafa opened this issue Mar 31, 2020 · 7 comments
Labels

Comments

@sa-mustafa
Copy link

Description

When CMake is used to build the MXNet 1.6.0 on Windows, some errors are generated pertaining to missing options.

Error Message

CMake Error at {build_path}/cmake-3.15/Modules/FindGTest.cmake:209 (add_library):

CMake Error at D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:209 (add_library):
  add_library called with IMPORTED argument but no library type.
Call Stack (most recent call first):
  CMakeLists.txt:477 (find_package)


CMake Error at D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:211 (set_target_properties):
  set_target_properties Can not find target to add properties to:
  GTest::GTest
Call Stack (most recent call first):
  CMakeLists.txt:477 (find_package)


CMake Error at D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:219 (set_target_properties):
  set_target_properties Can not find target to add properties to:
  GTest::GTest
Call Stack (most recent call first):
  CMakeLists.txt:477 (find_package)


CMake Error at D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:134 (set_property):
  set_property could not find TARGET GTest::GTest.  Perhaps it has not yet
  been created.
Call Stack (most recent call first):
  D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:224 (__gtest_import_library)
  CMakeLists.txt:477 (find_package)


CMake Error at D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:137 (set_target_properties):
  set_target_properties Can not find target to add properties to:
  GTest::GTest
Call Stack (most recent call first):
  D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:224 (__gtest_import_library)
  CMakeLists.txt:477 (find_package)


CMake Error at D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:143 (set_target_properties):
  set_target_properties Can not find target to add properties to:
  GTest::GTest
Call Stack (most recent call first):
  D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:224 (__gtest_import_library)
  CMakeLists.txt:477 (find_package)


CMake Error at D:/Build/cmake-3.15.0/share/cmake-3.15/Modules/FindGTest.cmake:228 (add_library):
  add_library called with IMPORTED argument but no library type.
Call Stack (most recent call first):
  CMakeLists.txt:477 (find_package)

To Reproduce

Just build the MXNet v1.6.0 project on Windows 8.1 (version is irrelevant). The CMake generates errors related to GTest options.

What have you tried to solve it?

Reading the CMake scripts helped find the cause. Two options are missing from the main CMakeList.txt file of the project. The CMake script needs to specify how to link with GTest library as shared/static/object or whatever. Just add the following two lines to CMakeList.txt @ line 472:

set(GTEST_LIBRARY_TYPE SHARED)
set(GTEST_MAIN_LIBRARY_TYPE SHARED)
@sa-mustafa sa-mustafa added the Bug label Mar 31, 2020
@leolikescoding
Copy link

hi i can successfully build mxnet cpp on linux operating system ,never tried windows op.
it seems that you have not installed the google test libs on your system.
After installing it , the cmake should find it automatically for you!

@sa-mustafa
Copy link
Author

Hi,
I manually introduce the library to cmake-gui, specifying the path. However, the errors suggest that the library type is not identified by cmake. Either the script should ask for the library type specifically, or it should be able to find it automatically.

@leezu
Copy link
Contributor

leezu commented Mar 31, 2020

Did you check out the https://github.com/apache/incubator-mxnet/blob/master/CMakeLists.txt#L479 3rdparty/googletest submodule?

@sa-mustafa
Copy link
Author

Yes. The https://github.com/apache/incubator-mxnet/blob/56e79853ad5cf98baf84454eb595c7658bef6ee6/CMakeLists.txt#L487 looks for GTest module. However, FindGTest.cmake module needs to know how to link your project with GTest: statically, dynamically. That's why I suggest to add options on Windows to specify the GTest library type.

@leezu
Copy link
Contributor

leezu commented Apr 1, 2020

Do you want to open a PR based on your suggestion?

@sa-mustafa
Copy link
Author

Yes, I'm sure adding the suggested lines improve the build experience on Windows. I've seen the problem since version 1.3.0 according to my personal notes. On Windows, installing DLL's separately is uncommon, so you have to specify the library type at build time.

@leezu
Copy link
Contributor

leezu commented Apr 1, 2020

Ok, please CC me in your PR. Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants