[CMake] target_link_libraries buggy with visual studio?

terje loe terjeloe at hotmail.com
Mon Jul 2 18:26:51 EDT 2012


Hi,
I'm trying to use target_link_libraries to add a release and debug version of a library to my debug and release config of my Visual Studyi project.
        message(${JSONCPP_LIB_DEBUG})
        message(${JSONCPP_LIB_RELEASE})
        target_link_libraries(
                TEEngineTest
                TECore
                TEngine
                TEGraphics
                TEPhysics
                TETransform
                ${cg_libs}
                ${libpng_lib}
                ${ASSIMP_LIB}
                debug ${JSONCPP_LIB_DEBUG}
                optimized ${JSONCPP_LIB_RELEASE})
When I'm generating it prints this:
D:/coding/tengine/Externals/jsoncpp/build/vs71/debug/lib_json/json_vc71_libmtd.lib
D:/coding/tengine/Externals/jsoncpp/build/vs71/release/lib_json/json_vc71_libmt.lib
Configuring done
Generating done
But when I look at the properties of the project it adds the release build of the lib to both debug and the release build?

Im not sure if this is relevant, but this is how I set up  my debug and release config for Visual Studio
if(MSVC)	set_property(GLOBAL PROPERTY USE_FOLDERS ON)	set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "9. CMake")			set(CMAKE_CONFIGURATION_TYPES "DebugOpenGL;ReleaseOpenGL;DebugDX11;ReleaseDX11")	set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING	"Reset the configurations to what we need"	FORCE)		#DebugOpenGL flags	set(CMAKE_CXX_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)	set(CMAKE_C_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi  /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)	set(CMAKE_EXE_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )	set(CMAKE_SHARED_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )
	#ReleaseOpenGL flags	set(CMAKE_CXX_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)	set(CMAKE_C_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)	set(CMAKE_EXE_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )	set(CMAKE_SHARED_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )		#DebugDX11 flags	set(CMAKE_CXX_FLAGS_DEBUGDX11 "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)	set(CMAKE_C_FLAGS_DEBUGDX11 "/D_DEBUG /MDd /Zi  /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)	set(CMAKE_EXE_LINKER_FLAGS_DEBUGDX11 "/debug /INCREMENTAL" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )	set(CMAKE_SHARED_LINKER_FLAGS_DEBUGDX11 "/debug /INCREMENTAL" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )		#ReleaseDX11 flags	set(CMAKE_CXX_FLAGS_RELEASEDX11 "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)	set(CMAKE_C_FLAGS_RELEASEDX11 "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)	set(CMAKE_EXE_LINKER_FLAGS_RELEASEDX11 "/INCREMENTAL:NO" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )	set(CMAKE_SHARED_LINKER_FLAGS_RELEASEDX11 "/INCREMENTAL:NO" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )		set_directory_properties(PROPERTIES		COMPILE_DEFINITIONS_DEBUGOPENGL TE_OPENGL		COMPILE_DEFINITIONS_RELEASEOPENGL TE_OPENGL		COMPILE_DEFINITIONS_DEBUGDX11 TE_DX11		COMPILE_DEFINITIONS_RELEASEDX11 TE_DX11)endif() 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120703/09b112a0/attachment.htm>


More information about the CMake mailing list