Mr. Boy
Mr. Boy

Reputation: 63816

Problems with CMAKE vars

I'm using CMAKE to generate VS2008 SLN/VCPROJ files but a few simple things don't appear to work:

1)This works: INCLUDE_DIRECTORIES ($ENV{MCS_OGRE_HOME}/OgreMain/include)

But this doesn't, my VC++ additional include dirs gets totally screwed up when I do this, brackets and all kinds floating around:

SET (OGRE_PATH $ENV{OGRE_HOME}/OgreMain)
INCLUDE_DIRECTORIES (${OGRE_PATH}/include)

2)This works: target_link_libraries( debug $ENV{OGRE_HOME}/lib/OgreMainStatic_d.lib )

But this doesn't, the library path isn't shown under the library paths in VC++:

LINK_DIRECTORIES($ENV{OGRE_HOME}/lib/)
target_link_libraries( debug OgreMainStatic_d.lib )

I figure it must be something simple?

Upvotes: 0

Views: 992

Answers (1)

DLRdave
DLRdave

Reputation: 14280

Rather than:

set(OGRE_PATH $ENV{OGRE_HOME}/OgreMain)

Use:

string(REPLACE "\\" "/" OGRE_PATH "$ENV{OGRE_HOME}/OgreMain")

CMake uses all "/" for path separators on all platforms.

Also, it's recommended to use full path names (with "/" separators) as library arguments to target_link_libraries rather than specifying link_directories. CMake then takes the whole set of libraries linked to and figures out the right order to pass linker flags on all platforms.

One more comment: looks like you have a library or an executable named "debug" from your call to target_link_libraries. Is that true? Or are you missing the first argument in the question posted here?

Should be something like:

target_link_libraries(mylib
  debug /path/to/DebugLib.lib
  optimized /path/to/ReleaseLib.lib)

Upvotes: 1

Related Questions