CMake仅为特定目标设置CMAKE_RUNTIME_OUTPUT_DIRECTORY

时间:2015-12-01 02:01:43

标签: cmake

我的整个项目使用

#include <iostream>
#include <memory>

using namespace std;

int main() {

    // compare the functionality of raw and smart pointers
    int* pA = new int(1);
    int* pB = new int(2);
    shared_ptr<int> pAsmart(new int(1));
    shared_ptr<int> pBsmart(new int(2));

    // pointer to a pointer
    int** ppA = &pA;
    shared_ptr< shared_ptr<int> > ppAsmart = make_shared< shared_ptr<int> >(pA);

    cout << **ppA << endl; // prints 1
    cout << **ppAsmart << endl; // prints 1

    pA = pB;
    pAsmart = pBsmart;

    cout << **ppA << endl; // prints 2
    cout << **ppAsmart << endl; // prints 1 (huh?)


}

将所有运行时二进制文件放在set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") 目录中。

但是我需要将一些dll放在一个名为&#34; scripts&#34;的子目录中, 我尝试使用以下代码为特定目标设置变量:

bin

但它不起作用,dll仍然位于set_target_properties(my_script_dll PROPERTIES CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/scripts" ) 下。

有没有办法只针对特定目标设置输出目录?

1 个答案:

答案 0 :(得分:1)

我通过使用:

解决了这个问题
Detected memory leaks!
Dumping objects ->
c:\users\cody\desktop\arraylist\arraylist\arraylist.cpp(48) : {4267} normal block at 0x007F9BC8, 3992 bytes long.
 Data: <                > 00 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 
Object dump complete.
The program '[16620] ArrayList.exe' has exited with code -1073741510 (0xc000013a).