[CMake] Binaries not ending up in the RUNTIME_OUTPUT_DIRECTORY

Michael Wild themiwi at gmail.com
Mon May 17 13:43:14 EDT 2010


Glad I could help.

The problem with globbing is that CMake doesn't notice when you add or remove a file, requiring you to re-run CMake manually every time you do so. And maintaining a list of source/header files in your CMake build system isn't that bad, really. If the list gets too long, you can easily put the list into e.g. a files.cmake file and INCLUDE that in the CMakeLists.txt.

Michael


On 17. May, 2010, at 17:50 , <aaron.meadows at thomsonreuters.com> <aaron.meadows at thomsonreuters.com> wrote:

> 
> AWESOME!  That's completely right!!!  Thanks for the quick response,
> this was really frustrating me!
> 
> So, file globs are evil?  Not to get off subject, but care to expand on
> that a bit?
> 
> Thanks for the help, I really appreciate it!!
> 
> Aaron C. Meadows 
> -----Original Message-----
> From: Michael Wild [mailto:themiwi at gmail.com] 
> Sent: Monday, May 17, 2010 10:30 AM
> To: Tyler Roscoe
> Cc: Meadows, Aaron C.; cmake at cmake.org
> Subject: Re: [CMake] Binaries not ending up in the
> RUNTIME_OUTPUT_DIRECTORY
> 
> Naaa, the variables are simply called CMAKE_RUNTIME_OUTPUT_DIRECTORY,
> CMAKE_LIBRARY_OUTPUT_DIRECTORY and CMAKE_ARCHIVE_OUTPUT_DIRECTORY. Aaron
> mixed them up with the respective target property names
> 
> A few other things:
> 
> - you can call INCLUDE_DIRECTORIES with more than one directory
> - NEVER use FILE(GLOB ...), it is evil.
> 
> 
> Michael
> 
> On 17. May, 2010, at 17:21 , Tyler Roscoe wrote:
> 
>> You probably need the Prefix Hack:
>> http://www.itk.org/Bug/view.php?id=8243
>> 
>> tyler
>> 
>> On Mon, May 17, 2010 at 09:53:34AM -0500,
> aaron.meadows at thomsonreuters.com wrote:
>>> Hi All!
>>> 
>>> 
>>> 
>>> I'm trying to migrate an existing Visual Studio 8 2005 source tree to
>>> CMake.  The only problem I'm having right now is getting the build
>>> artifacts to end up in the directories I want them in.  I would like
>>> everything to show up in the ${PROJECT_BINARY_DIR}/bin dir, but only
>>> static libraries are showing up there.  In particular, I have noticed
>>> this as I've been adding post build steps to call my unit tests.
> I'll
>>> include my root CMakeLists.txt and the UnitTest CMakeLists.txt.  If
>>> anyone can spot the issue, I'd be grateful! (Any other suggestions
>>> welcome as well!)
>>> 
>>> 
>>> 
>>> ( Note, the MESSAGE() calls show that the two variables are defined
>>> correctly in both CMakeLists.txt files. )
>>> 
>>> 
>>> 
>>> Root CMakeLists.txt (./CmakeLists.txt)
>>> 
>>> cmake_minimum_required (VERSION 2.6)
>>> 
>>> 
>>> 
>>> set(CMAKE_USER_MAKE_RULES_OVERRIDE
>>> 
>>>  ${CMAKE_CURRENT_SOURCE_DIR}/c_flag_overrides.cmake)
>>> 
>>> set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
>>> 
>>>  ${CMAKE_CURRENT_SOURCE_DIR}/cxx_flag_overrides.cmake)
>>> 
>>> 
>>> 
>>> project (VersionInfo CXX)
>>> 
>>> 
>>> 
>>> # Default Include Dir
>>> 
>>> include_directories("${PROJECT_SOURCE_DIR}")
>>> 
>>> include_directories("$ENV{RDFD3RDPARTYDIR}/include")
>>> 
>>> 
>>> 
>>> link_directories("$ENV{RDFD3RDPARTYDIR}/lib")
>>> 
>>> if(DEBUG)
>>> 
>>> link_directories("$ENV{RDFD3RDPARTYDIR}/lib/Debug")
>>> 
>>> else()
>>> 
>>> link_directories("$ENV{RDFD3RDPARTYDIR}/lib/Release")
>>> 
>>> endif()
>>> 
>>> 
>>> 
>>> # New style of output location... doesn't seem to be supported in my
>>> version of CMake
>>> 
>>> SET( RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
>>> 
>>> SET( LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
>>> 
>>> SET( ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
>>> 
>>> 
>>> 
>>> # Old style of output location... still works
>>> 
>>> SET( RUNTIME_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin )
>>> 
>>> SET( LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin )
>>> 
>>> SET( ARCHIVE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin )
>>> 
>>> LINK_DIRECTORIES( ${LIBRARY_OUTPUT_DIRECTORY})
>>> 
>>> 
>>> 
>>> ENABLE_TESTING()
>>> 
>>> 
>>> 
>>> MESSAGE("Master: Runtime_output_path: ${RUNTIME_OUTPUT_PATH} ")
>>> 
>>> MESSAGE("Master: Runtime_output_directory:
> ${RUNTIME_OUTPUT_DIRECTORY}
>>> ")
>>> 
>>> 
>>> 
>>> add_definitions(-D_SCL_SECURE_NO_WARNINGS)
>>> 
>>> 
>>> 
>>> # Library projects
>>> 
>>> add_subdirectory(Toolbox)
>>> 
>>> add_subdirectory(VersionSystem)
>>> 
>>> 
>>> 
>>> # Executables
>>> 
>>> add_subdirectory(VersionCompiler)
>>> 
>>> add_subdirectory(ReadVer)
>>> 
>>> 
>>> 
>>> # Test Projects
>>> 
>>> add_subdirectory(TestLib1)
>>> 
>>> add_subdirectory(TestLib2)
>>> 
>>> add_subdirectory(TestDLL)
>>> 
>>> add_subdirectory(TestEXE)
>>> 
>>> 
>>> 
>>> 
>>> 
>>> UnitTest CMakeLists.txt (./VersionSystem/UnitTests/CMakeLists.txt)
>>> 
>>> FILE( GLOB interfacefiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h
> *.hpp
>>> )
>>> 
>>> FILE( GLOB srcfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h *.hpp
> *.cpp
>>> *.c )
>>> 
>>> 
>>> 
>>> SOURCE_GROUP( Interface FILES ${interfacefiles} )
>>> 
>>> SOURCE_GROUP( Source FILES ${srcfiles} )
>>> 
>>> 
>>> 
>>> ADD_EXECUTABLE( VersionSystem-UT ${srcfiles} )
>>> 
>>> TARGET_LINK_LIBRARIES( VersionSystem-UT VersionSystem )
>>> 
>>> 
>>> 
>>> MESSAGE("VersionSystem-UT: Runtime_output_path:
> ${RUNTIME_OUTPUT_PATH}
>>> ")
>>> 
>>> MESSAGE("VersionSystem-UT: Runtime_output_directory:
>>> ${RUNTIME_OUTPUT_DIRECTORY} ")
>>> 
>>> 
>>> 
>>> ADD_CUSTOM_COMMAND(TARGET VersionSystem-UT POST_BUILD COMMAND
>>> VersionSystem-UT.exe WORKING_DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY} )
>>> 
>>> #ADD_TEST( VersionSystem VersionSystem-UT )
>>> 
>>> 
>>> 
>>> Directory Structure and CMakeLists.txt locations:
>>> 
>>> ./CMakeLists.txt
>>> 
>>> ./ReadVer/CMakeLists.txt
>>> 
>>> ./ReadVer/UnitTests/CMakeLists.txt
>>> 
>>> ./TestDLL/CMakeLists.txt
>>> 
>>> ./TestDLL/UnitTests/CMakeLists.txt
>>> 
>>> ./TestEXE/CMakeLists.txt
>>> 
>>> ./TestEXE/UnitTests/CMakeLists.txt
>>> 
>>> ./TestLib1/CMakeLists.txt
>>> 
>>> ./TestLib1/UnitTests/CMakeLists.txt
>>> 
>>> ./TestLib2/CMakeLists.txt
>>> 
>>> ./TestLib2/UnitTests/CMakeLists.txt
>>> 
>>> ./Toolbox/CMakeLists.txt
>>> 
>>> ./Toolbox/UnitTests/CMakeLists.txt
>>> 
>>> ./VersionCompiler/CMakeLists.txt
>>> 
>>> ./VersionCompiler/UnitTests/CMakeLists.txt
>>> 
>>> ./VersionSystem/CMakeLists.txt
>>> 
>>> ./VersionSystem/UnitTests/CMakeLists.txt
>>> 
>>> 
>>> 
>>> Aaron Meadows
>>> Software Engineer
>>> 
>>> Thomson Reuters
>>> 
>>> Phone: 314.468.3530
>>> Mobile: 636.541.6139
>>> aaron.meadows at thomsonreuters.com
>>> thomsonreuters.com
> 
> 
> 
> This email was sent to you by Thomson Reuters, the global news and information company.
> Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list