[CMake] How to invoke a separate build with CMAKE_CUSTOM_TARGET?
Michael Hertling
mhertling at online.de
Mon May 16 18:58:30 EDT 2011
On 05/13/2011 08:36 AM, Heine, Christian (EXTERN: VWGEDS) wrote:
> I've followed your instructions, removed the obsolete lines but
> no effect, the libbrOpenGL.dll which is located at ./lib is still
> missing on startup ...
>
> The br* stuff are my dependencies library which I've created
> and installed separatelly, not in context of the actual project.
> The resulting dll's of those modules are installed to system32
> folder.
>
> What I've figured out is, that anything works if I place the
> libbrOpenGL.dll directly in the module/cmake root folder and
> not at lib subdirectory ...
The libbrOpenGL.dll in ./lib despite CMAKE_RUNTIME_OUTPUT_DIRECTORY
set to a different location probably means that this variable isn't
in effect for the brOpenGL target. Did you enable it for the latter,
too, or just for the mydemo executable target? If the problem still
persists, could you boil it down to a minimal but complete example,
i.e. one trivial executable linking against one trivial library,
and post this little project here for further investigation?
Usually, setting CMAKE_RUNTIME_OUTPUT_DIRECTORY et al. is a good advice
to collect executables and shared libraries at a common location so the
latters are found by the formers in the build tree without further ado
on Windows. Alternatively, you might set up a dedicated installation
component driven by a custom target which preliminarily installs the
binaries in the build tree for testing or demonstration purposes:
INSTALL(TARGETS mydemo brOpenGL
RUNTIME DESTINATION ${CMAKE_BINARY_DIR}/bin
LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib
ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib
COMPONENT demo)
ADD_CUSTOM_TARGET(demo ${CMAKE_COMMAND} -DCOMPONENT=demo
-P ${CMAKE_BINARY_DIR}/cmake_install.cmake)
ADD_DEPENDENCIES(demo mydemo brOpenGL)
In this way, you could additionally perform some actions necessary for
the mydemo executable to run from within the build tree, e.g. provide
exemplary configuration and data files.
'hope that helps.
Regards,
Michael
PS: Don't write to the source tree; in particular, variables like
CMAKE_RUNTIME_OUTPUT_DIRECTORY should denote directories in
the build tree, i.e. beneath CMAKE_BINARY_DIR.
^^^^^^
>> Mit freundlichen Grüßen
>>
> Christian Heine
>
> T-Systems on site services GmbH
> Procurement Systems
>
>> Telefon/phone: +49-5361-9-78564
>> E-Mail: extern.christian.heine at volkswagen.de
>>
> --------------------------------------------------------------------------------
>
> Christian Heine
> Consultant
> Alessandro-Volta-Straße 11, 38440 Wolfsburg
> +49-5361-464 78-x (Tel.)
> +49-5361-464 78-10 (Fax)
> E-Mail: christian.heine at t-systems.com
> Internet: http://www.t-systems-onsite.de
>
> Geschäftsführung: Stefan Kappe, Georg Rätker
> Handelsregister: Amtsgericht Berlin HRB 51336
> Sitz der Gesellschaft: Berlin
> Ust.-Id Nr. DE 181 120 485
>
> --------------------------------------------------------------------------------
>
> Notice: This transmittal and/or attachments may be privileged or confidential. If you are not the intended recipient, you are hereby notified that you have received this transmittal in error; any review, dissemination, or copying is strictly prohibited. If you received this transmittal in error, please notify us immediately by reply and immediately delete this message and all its attachments. Thank you.
>
> -----Ursprüngliche Nachricht-----
> Von: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] Im Auftrag von Rolf Eike Beer
> Gesendet: Donnerstag, 12. Mai 2011 17:29
> An: cmake at cmake.org
> Betreff: Re: [CMake] How to invoke a separate build with CMAKE_CUSTOM_TARGET?
>
> Am Donnerstag, 12. Mai 2011, 14:51:42 schrieb Heine, Christian:
>> Hmm, this is strange. I've followed your instructions, but those take no
>> effect. When i try to run the executable I got the failure message box that
>> my libbrOpenGL.dll of the acutal build result is missing. Here is what I do
>> on demo build:
>>
>> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
>> ${CMAKE_CURRENT_SOURCE_DIR}
>> ${CMAKE_SOURCE_DIR}/include
>> ${COMPILER_ROOT}/include/binrev
>> )
>>
>> # Find OpenGL library using default CMake find script
>> FIND_PACKAGE(OpenGL REQUIRED)
>>
>> # create output directory
>> SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
>>
>> # Make sure the linker can find our libraries once they are built.
>> LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib)
>
> This is basically always wrong. Since you usually pass absolute paths to
> target_link_libraries() this doesn't help in any way but may cause trouble.
> Just don't do it.
>
>> # Find our cmake utils with different reusable macros
>> FIND_PACKAGE(OpenGL REQUIRED)
>
> You already did that before.
>
>> # create exectuable
>> SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
>
> Since CMAKE_RUNTIME_OUTPUT_DIRECTORY is already set you should not need that
> anymore.
>
>> ADD_EXECUTABLE(mydemo demo_win32Camera.cpp)
>>
>> #link test libraries for unit tests
>> TARGET_LINK_LIBRARIES( mydemo
>> brOpenGL # this is the library of the actual build
>> brCore brMath brGraphics # this are other required
> libs
>> )
>
> These br* things are be created by add_library(... shared ...) in your
> project, no? Then this should work if you had previously set
> CMAKE_LIBRARY_OUTPUT_DIRECTORY to bin or so.
>
> Eike
More information about the CMake
mailing list