Skip to content

Fixes (?) to add_debug_variants#201

Closed
aothms wants to merge 2 commits into
IfcOpenShell:masterfrom
aothms:add_debug_variants_fixes
Closed

Fixes (?) to add_debug_variants#201
aothms wants to merge 2 commits into
IfcOpenShell:masterfrom
aothms:add_debug_variants_fixes

Conversation

@aothms

@aothms aothms commented Apr 3, 2017

Copy link
Copy Markdown
Member

@Stinkfist0 I ran into this problem, that if CMake runs against debug libraries of OCCT, that already have a _d postfix, it would try to link to TKerneldd.lib, i.e. double d.

Perhaps in this particular case, no release libs where available in the dir, so FIND_LIBRARY(libTKernel NAMES TKernel TKerneld can only return the TKerneld.lib.

Then in [1] (which I believe was added by me after your add_debug_variants()) this _d is not accounted for.

Somehow I ended making more changes than I anticipated, because I kept ending up with a structure like: TKernel.lib GENERAL TKernel.lib DEBUG TKernel.lib. So overcautiously I made sure add_debug_variants() does not append to a pre-existing list.

Does this look somewhat reasonable to you?

[1]

# Use the found libTKernel as a template for all other OCC libraries
foreach(lib ${OPENCASCADE_LIBRARY_NAMES})
    string(REPLACE TKernel "${lib}" lib_path "${libTKernel}")
    list(APPEND OPENCASCADE_LIBRARIES_RELEASE "${lib_path}")
endforeach()

@Stinkfist0

Stinkfist0 commented Apr 3, 2017

Copy link
Copy Markdown
Contributor

I'll have a deeper look into this: I also noticed that add_debug_variants() in malfunctioning in general and the Debug-Release switching is broken. I'll dig into this in conjunction with VS 2017 support work.

@aothms

aothms commented Apr 5, 2017

Copy link
Copy Markdown
Member Author

@Stinkfist0 that would be great. Just fixed the PR to work on nix.

@aothms

aothms commented May 3, 2017

Copy link
Copy Markdown
Member Author

@Stinkfist0 did you manage to have a look?

@Stinkfist0

Copy link
Copy Markdown
Contributor

Sorry, got derailed with this, I'll try to take a look tonight and report back.

@aothms

aothms commented May 3, 2017

Copy link
Copy Markdown
Member Author

No worries, not urgent

@Stinkfist0

Stinkfist0 commented May 5, 2017

Copy link
Copy Markdown
Contributor

Unfortunately I didn't have still time to look into this properly, but I think the root of the Release/Debug switching problems is the point when usage of link_directories() and link_libraries() was removed. IIRC, after that change I needed to introduce add_debug_variants(). Prior to that I think all worked perfectly fine without any custom code, at least on Windows/MSVC. These two built-in CMake functions should also handle paths fine spaces fine.

@Stinkfist0

Copy link
Copy Markdown
Contributor

OK, finally have the time to properly look into this. Should be done by tonight.

Stinkfist0 added a commit to Tridify/IfcOpenShell that referenced this pull request May 11, 2017
@aothms

aothms commented May 13, 2017

Copy link
Copy Markdown
Member Author

Unfortunately I didn't have still time to look into this properly, but I think the root of the Release/Debug switching problems is the point when usage of link_directories() and link_libraries() was removed.

Well, I agree the amount of custom code to do some simple library linking doesn't feel right. The commit you are referring to is e9bd18f based on this issue #111

The problem being solved there is that if you refer to libs as a pair of <path, name> rather than just path/name you run into issues if there are libraries installed into (default) library locations (possibly referred to by other deps). I.e. you no longer have full control over what the linker is going to pick when there are multiple versions of one dep installed (e.g. oce from package manager and manually compiled).

Also note the CMake docs recommending against link_directories() [1]

Note that this command is rarely necessary. Library locations returned by find_package() and find_library() are absolute paths. Pass these absolute library file paths directly to the target_link_libraries() command. CMake will ensure the linker finds them.

So, with #217 this can be closed?

[1] https://cmake.org/cmake/help/v3.2/command/link_directories.html

@Stinkfist0

Copy link
Copy Markdown
Contributor

Yeah, upon more thought specifying the full filename of the library feels better than the path-filename pair. Maybe in the future we can cook up a bit nicer and cleaner unified approach for this as the current CMake script is becoming quite convoluted. If the new PR looks good enough (better than this PR), yeah, this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants