qPCR4vir / nana-demo

demos and tests for Nana C++ GUI library
https://github.com/cnjinhao/nana
Boost Software License 1.0
68 stars 24 forks source link

How to specify location of nana library when building demos? #8

Open steveking-gh opened 8 years ago

steveking-gh commented 8 years ago

Hi, using CMake and gcc 5.3 on Fedora 23 64-bit - In the CMakeLists.txt file for the demos, I did not see a way to specify the location of the nana build directory in order to find the libarry file. The linker fails with missing -lnana. How should I specify the location of the nana build?

qPCR4vir commented 8 years ago

Well, from: install in cmake Install Specify rules to run at install time.

This command generates installation rules for a project. Rules specified by calls to this command within a source directory are executed in order during installation. The order across directories is not defined.

There are multiple signatures for this command. Some of them define installation options for files and targets. Options common to multiple signatures are covered here but they are valid only for signatures that specify them. The common options are:

DESTINATION Specify the directory on disk to which a file will be installed. If a full path (with a leading slash or drive letter) is given it is used directly. If a relative path is given it is interpreted relative to the value of the CMAKE_INSTALL_PREFIX variable. The prefix can be relocated at install time using the DESTDIR mechanism explained in the CMAKE_INSTALL_PREFIX variable documentation.

Static libraries are always treated as ARCHIVE targets.

I think in my case all of this is managed by CLion or by travis some how. But it works.

qPCR4vir commented 8 years ago

In fact what we need is to actualize the CMakeFile in the nana-demo repo. I don't whant to introduce too much spurious commits into the nana repo that actually belong to the nana-demo repo. But I know very little about cmake, sorry. I'm learning now.

steveking-gh commented 8 years ago

The long term solution is to write a CMake find_package() module for nana, then use that find_package in the CMakeLists.txt of the demos repo. There are examples of doing this in the CMake documentation. In my case, I'd need to keep the nana library installation path in a project directory, not in /usr/lib. I used CMAKE_INSTALL_PREFIX, but demos of course does not find my weird location. So, some -DNANA_INSTALL_DIR override would help. Thanks for the excellent support by the way. I'm encouraged about using nana.

steveking-gh commented 8 years ago

Directory assumptions like this (from demos CMakeLists.txt) are trouble: include_directories(${CMAKE_SOURCE_DIR}/../nana/include) link_directories(${CMAKE_SOURCE_DIR}/../nana/ShadowBuild)

liubenyuan commented 4 years ago

@steve6390 I think this assumption is ok for this demo and learning nana.