[CMake] Outputting targets to subdirectories

Lars Sønderby Jessen ljessen at ljessen.dk
Fri Jun 4 06:38:09 EDT 2010


Hi,

I have a project where I need to generate 2 target files in different folders:

<OUTPUT_DIR>/myapp.exe
<OUTPUT_DIR>/plugins/myplugin.dll

I've created the following CMakeLists.txt:
<SOURCE_DIR>/CMakeLists.txt
<SOURCE_DIR>/plugins/CMakeLists.txt

With the following contents:

<SOURCE_DIR>/CMakeLists.txt:
	
cmake_minimum_required(VERSION 2.8)
project(myproject)
add_executable(myexe main.cxx)
add_subdirectory(plugins)


<SOURCE_DIR>/plugins/CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
set(RUNTIME_OUTPUT_DIRECTORY plugins)
add_library(myplugin SHARED myplugin.cxx) 

But this produces the following output:
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/myexe.exe
${CMAKE_CURRENT_BINARY_DIR}/plugins/${CMAKE_CFG_INTDIR}/myplugin.dll

How can I change the 2nd CMakeLists.txt file such that I get the following output:
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/myexe.exe
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/plugins/myplugin.dll

?


- Lars


More information about the CMake mailing list