Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem #1067 - RUNTIME_OUTPUT_DIRECTORY #1088

Merged
merged 3 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/drivers/cmakefileapi/api_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ async function convertTargetObjectFileToExtensionTarget(build_dir: string, file_
if (targetObject.artifacts) {
executable_path = targetObject.artifacts.find(artifact => artifact.path.endsWith(targetObject.nameOnDisk));
if (executable_path) {
executable_path = path.normalize(path.join(build_dir, executable_path.path));
if (await fs.exists(executable_path.path)) {
executable_path = path.normalize(executable_path.path);
} else {
executable_path = path.normalize(path.join(build_dir, executable_path.path));
if (!fs.exists(executable_path)) {
// Will be empty after cmake configuration
executable_path = "";
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit-tests/driver/driver-codemodel-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ export function makeCodeModelDriverTestsuite(
}).timeout(90000);


test('Test first executable target directory', async () => {
test('Test executable target information', async () => {
const codemodel_data = await generateCodeModelForConfiguredDriver();
expect(codemodel_data).to.be.not.null;

const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'EXECUTABLE');
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'EXECUTABLE' && t.name == 'TestBuildProcess');
expect(target).to.be.not.undefined;

// Test target name used for node label
Expand Down
11 changes: 8 additions & 3 deletions test/unit-tests/driver/driver-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,14 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
expect(await driver.cleanConfigure([])).to.be.eq(0);
expect(await driver.build(driver.allTargetName)).to.be.eq(0);

expect(driver.executableTargets.length).to.be.eq(1);
expect(driver.executableTargets[0].name).to.be.equal('TestBuildProcess');
expect(fs.existsSync(driver.executableTargets[0].path)).to.be.true;
expect(driver.executableTargets.length).to.be.eq(2);
const targetInTopLevelBuildDir = driver.executableTargets.find(t => t.name == 'TestBuildProcess');
expect(targetInTopLevelBuildDir).to.not.undefined;
expect(fs.existsSync(targetInTopLevelBuildDir!.path)).to.be.true;

const targetInRuntimeOutputDir = driver.executableTargets.find(t => t.name == 'TestBuildProcessOtherOutputDir');
expect(targetInRuntimeOutputDir).to.not.undefined;
expect(fs.existsSync(targetInRuntimeOutputDir!.path)).to.be.true;
}).timeout(90000);

test('Configure fails on invalid preferred generator', async () => {
Expand Down
16 changes: 16 additions & 0 deletions test/unit-tests/driver/workspace/test_project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ add_subdirectory(shared_lib_dummy)
add_executable(TestBuildProcess main.cpp)
set_property(TARGET TestBuildProcess PROPERTY CXX_STANDARD 98)

add_executable(TestBuildProcessOtherOutputDir main.cpp)
set_property(TARGET TestBuildProcessOtherOutputDir PROPERTY CXX_STANDARD 98)

set_target_properties( TestBuildProcessOtherOutputDir
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
)
target_compile_definitions(TestBuildProcessOtherOutputDir PRIVATE
"CMT_COOKIE=\"${CMT_COOKIE}\""
"C_COMPILER_ID=\"${CMAKE_C_COMPILER_ID}\""
)
target_link_libraries(TestBuildProcessOtherOutputDir StaticLibDummy)

add_custom_command(
TARGET TestBuildProcess
POST_BUILD
Expand All @@ -17,6 +32,7 @@ add_custom_command(
COMMENT "Running in ${CMAKE_CURRENT_BINARY_DIR}"
)


set(extraArgsEnvironment "${EXTRA_ARGS_TEST}" CACHE STRING "environment")
set(configureEnvironment "$ENV{_CONFIGURE_ENV}" CACHE STRING "configureEnvironment")
set(buildEnvironment "$ENV{_BUILD_ENV}" CACHE STRING "buildEnvironment")
Expand Down