MantisBT - CMake
View Issue Details
0015905CMakeCMakepublic2016-01-06 02:062016-05-02 08:30
Ivan K 
 
normalminoralways
closedsuspended 
Win 7 x64
CMake 3.4.1 
 
0015905: It seems that CMake ignores "Debug" in CMAKE_TRY_COMPILE_CONFIGURATION
https://github.com/urho3d/Urho3D/issues/1136#issuecomment-169250581 [^]
No tags attached.
Issue History
2016-01-06 02:06Ivan KNew Issue
2016-01-08 09:46Brad KingNote Added: 0040154
2016-01-08 09:55Brad KingNote Added: 0040155
2016-01-08 17:09Ivan KNote Added: 0040165
2016-01-08 17:12Ivan KNote Edited: 0040165bug_revision_view_page.php?bugnote_id=40165#r1992
2016-01-08 17:46Ivan KNote Added: 0040166
2016-01-08 17:53Ivan KNote Deleted: 0040166
2016-01-08 20:06Ivan KNote Added: 0040167
2016-01-08 20:14Ivan KNote Deleted: 0040167
2016-01-08 20:18Ivan KNote Added: 0040168
2016-01-08 20:36Ivan KNote Added: 0040169
2016-01-11 11:39Brad KingNote Added: 0040189
2016-01-11 11:44Brad KingNote Added: 0040190
2016-01-11 11:44Brad KingStatusnew => resolved
2016-01-11 11:44Brad KingResolutionopen => suspended
2016-01-11 12:50Brad KingNote Added: 0040191
2016-05-02 08:30Robert MaynardNote Added: 0041000
2016-05-02 08:30Robert MaynardStatusresolved => closed

Notes
(0040154)
Brad King   
2016-01-08 09:46   
Thanks for forwarding this report!

I'd prefer not to set up an entire Urho3D build, but I cannot reproduce this in a simple example. Here is a session:

------------------------------------------------------------------------
$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
project(Issue15905 C)

set(CMAKE_TRY_COMPILE_CONFIGURATION Debug)

include(CheckCSourceCompiles)

unset(RESULT CACHE)
CHECK_C_SOURCE_COMPILES([[
int main(void) { return 0; }
]] RESULT)

$ cmake --version
cmake version 3.4.1
...

$ cmake .. -G "Visual Studio 14 2015"
...

$ grep -A 3 'Performing C SOURCE FILE Test RESULT' CMakeFiles/CMakeOutput.log
Performing C SOURCE FILE Test RESULT succeded with the following output:
Change Dir: C:/.../CMakeFiles/CMakeTmp

Run Build Command:"C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe" "cmTC_a30ca.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=14.0"
------------------------------------------------------------------------

If I change the CMAKE_TRY_COMPILE_CONFIGURATION to "Release" then the log instead shows:

Run Build Command:"C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe" "cmTC_ceffb.vcxproj" "/p:Configuration=Release" "/p:VisualStudioVersion=14.0"

Can you provide a http://sscce.org/ [^] ?
(0040155)
Brad King   
2016-01-08 09:55   
In the log linked by https://github.com/urho3d/Urho3D/issues/1136#issuecomment-169240799 [^] at http://pastebin.com/hRX5a64L [^] one can see that MSBuild is invoked with "/p:Configuration=Release". If CMAKE_TRY_COMPILE_CONFIGURATION is not set then the default should be Debug:

 https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalVisualStudio10Generator.cxx;hb=v3.4.1#l532 [^]

Therefore it seems CMAKE_TRY_COMPILE_CONFIGURATION is somehow still set to "Release". It may be that some other behavior change between CMake 3.3 and 3.4 is showing up in Urho3D as this symptom.
(0040165)
Ivan K   
2016-01-08 17:09   
(edited on: 2016-01-08 17:12)
> Can you provide a http://sscce.org/ [^] [^] ?

Sorry, I am not the author of cmake config in Urho. Also my knowledges of CMAKE language is very badly. I can not give detailed answers :(

(0040168)
Ivan K   
2016-01-08 20:18   
I insert string before try_run and it execution twice (!) with various values (Debug then Release)

            message (STATUS ${CMAKE_TRY_COMPILE_CONFIGURATION})

            try_run (URHO3D_RUN_RESULT URHO3D_COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR}/CheckUrho3DLibrary.cpp
                CMAKE_FLAGS ${IOS_FLAGS} -DLINK_LIBRARIES:STRING=${URHO3D_LIBRARIES}\;${BCM_VC_LIBRARIES}\;${ANDROID_LIBRARIES} -DINCLUDE_DIRECTORIES:STRING=${URHO3D_INCLUDE_DIRS} ${COMPILER_32BIT_FLAG} ${COMPILER_STATIC_FLAG}
                COMPILE_OUTPUT_VARIABLE TRY_COMPILE_OUT RUN_OUTPUT_VARIABLE TRY_RUN_OUT)

-----------------------


Output:

Debug
Error copying file (if different) from "
D:/MyGames/MiniGame/Src/bin/CoreData" to "D:/MyGames/MiniGame/Bin/bin/CoreData".

Error copying file (if different) from "
D:/MyGames/MiniGame/Src/bin/Data" to "D:/MyGames/MiniGame/Bin/bin/Data".

Release
CMake Error at CMake/Modules/FindUrho3D.cmake:330 (message):
  Could NOT find compatible Urho3D library in Urho3D SDK installation or
  build tree. Use URHO3D_HOME environment variable or build option to
  specify the location of the non-default SDK installation or build tree.
  Ensure the specified location contains the Urho3D library of the requested
  library type. Change Dir: D:/MyGames/MiniGame/Bin/CMakeFiles/CMakeTmp
(0040169)
Ivan K   
2016-01-08 20:36   
In Cmake 3.3 only one message - Debug
(0040189)
Brad King   
2016-01-11 11:39   
Okay. It appears in order to reproduce this one must build Urho3D and then build an application that uses FindUrho3D to look for the output of the first build. It is the latter step that fails with the reported error. This process is a bit heavy for me to follow myself. However, looking at the code I see the try_run call here:

 https://github.com/urho3d/Urho3D/blob/e5f07d790adc60066ff0eb8776d911c4453be35f/CMake/Modules/FindUrho3D.cmake#L252-L254 [^]

It is inside a loop bounded here:

 https://github.com/urho3d/Urho3D/blob/e5f07d790adc60066ff0eb8776d911c4453be35f/CMake/Modules/FindUrho3D.cmake#L167 [^]

The CMAKE_TRY_COMPILE_CONFIGURATION value is determined in each iteration here:

 https://github.com/urho3d/Urho3D/blob/e5f07d790adc60066ff0eb8776d911c4453be35f/CMake/Modules/FindUrho3D.cmake#L232-L236 [^]

based on URHO3D_LIBRARIES_REL which is set earlier in the loop here:

 https://github.com/urho3d/Urho3D/blob/e5f07d790adc60066ff0eb8776d911c4453be35f/CMake/Modules/FindUrho3D.cmake#L175-L182 [^]

That logic looks a bit flaky and will change behavior based on whether debug and/or release libraries were found in the previous iteration of the loop.

It may be possible that a change to CMake's find_library or related capabilities between CMake 3.3 and 3.4 affect the find results and therefore the logic. Likely the above-linked logic in FindUrho3D was working only by accident before due to the combination of what is found.
(0040190)
Brad King   
2016-01-11 11:44   
Re 0015905:0040189: Due to the logic linked in FindUrho3D I do not think this trouble has been demonstrated to be a real bug in CMake, so for now I'm resolving this as "suspended". If someone (perhaps from Urho3D) can narrow this down to a http://sscce.org/ [^] showing a regression in CMake then we can re-open this with such information.
(0040191)
Brad King   
2016-01-11 12:50   
For reference, Urho3D should provide CMake package files:

 https://cmake.org/cmake/help/v3.4/manual/cmake-packages.7.html [^]

instead of asking clients to use a Find module. Since the packaging files come with the project they describe there is no guesswork involved in finding what is available.
(0041000)
Robert Maynard   
2016-05-02 08:30   
Closing resolved issues that have not been updated in more than 4 months.