Merge lp:~davidagraf/zorba/bug-1013075 into lp:zorba

Proposed by David Graf on 2012-06-14
Status: Merged
Approved by: David Graf on 2012-07-06
Approved revision: 10871
Merged at revision: 10917
Proposed branch: lp:~davidagraf/zorba/bug-1013075
Merge into: lp:zorba
Diff against target: 138 lines (+40/-23)
2 files modified
CMakeLists.txt (+17/-6)
cmake_modules/ZorbaGenerateExe.cmake (+23/-17)
To merge this branch: bzr merge lp:~davidagraf/zorba/bug-1013075
Reviewer Review Type Date Requested Status
Rodolfo Ochoa 2012-06-14 Approve on 2012-07-05
Dennis Knochenwefel 2012-06-14 Approve on 2012-06-14
Review via email: mp+110307@code.launchpad.net

Commit message

Unifying .bat and .vcproj generation. Bug #1013075

Description of the change

To post a comment you must log in.
David Graf (davidagraf) wrote :

Dennis, you found this problem in sausalito. Can you please test this Zorba proposal on your machine to see if the Visual Studio project files are generated properly?

tested a clean build with vs 2010 on windows. works. thanks.

review: Approve
David Graf (davidagraf) wrote :

Chris, can you please review this fix?
Thanks

Chris Hillery (ceejatec) wrote :

I really can't; I know very little about how builds work in MSVC and don't have access to that IDE for testing it.

Can you briefly explain what you did and why? Then I'd suggest having Rodolfo review it.

David Graf (davidagraf) wrote :

'Small' explanation:

On Windows, there isn't something like an RPath or a default library search path. Therefore, all libraries which an executable depends on need to be in the PATH. Thus, we generate for each executable in Zorba a bat file to set the PATH variable properly before executing it (e.g. \bin\zorba.bat).

So, when we wanna execute an exe from the build directory in the cmd, you can execute the bat. This is also used for ctests. E.g. the rbkt testdriver is executed via the testdriver.bat file.

Now, there are some guys in the Zorba team using Visual Studio ( :-) ). Those people wanna be able to execute the exes from visual studio, e.g. for debugging. But Visual Studio does execute the exes directly. There is no way to tell visual studio to execute the bat files instead. So, the trick to set PATH in bat files does not work. But some years ago, we found a bypass by generation the Visual Studio project files for each executable manually and set the PATH variable there.

Unfortunately, this mechanism got forgotten when someone changed the bat file generation mechanism. Bat file needs to be generated at the end of cmake to get all PATH entries in. So, what I am doing in this change is: I make the vcproj file generation equal to the bat file generation. That's all :-).

Please feel free to replace yourself with Rodolfo!

Chris Hillery (ceejatec) wrote :

Thanks for the information. I'm always interested (in a traffic-accident kind of way) about how development on Windows work.

I do think it would make more sense for Rodolfo to test/review this change than me, so I've updated the request.

review: Approve
Rodolfo Ochoa (rodolfo-ochoa) wrote :

Is not working on my VS, I have:
Error 146 error LNK1181: cannot open input file '..\..\src\Release\zorba_simplestore.lib'

review: Needs Fixing
David Graf (davidagraf) wrote :

Is this error msg really released to my change? Does this happen when you do a clean visual studio build?

Rodolfo Ochoa (rodolfo-ochoa) wrote :

No, seems that the error is on trunk... just give me a few hours and I will fix it and approve also this branch...

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1013075-2012-07-06T08-12-08.905Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2012-05-22 16:55:02 +0000
3+++ CMakeLists.txt 2012-06-14 12:20:25 +0000
4@@ -148,12 +148,13 @@
5 ENDIF (WIN32)
6
7 ################################################################################
8-# This section is used for batch script generation. Each executable
9-# on Windows needs a bat script in order to set the PATH to the required DLLs.
10+# This section is used for batch script and Visual Studio Project file generation.
11+# Each executable on Windows needs a bat script and in the Visual Studio build a \
12+# pre-generated Visual Studio Project file in order to set the PATH to the required DLLs.
13 # For this we use CACHE variables to gather all the information generated
14 # throughout the cmake execution (required DLLs, list of scripts to generate).
15 # The generation occurs only at the end of CMake execution (through the macro
16-# ZORBA_GENERATE_EXE_SCRIPTS_WIN32) when ALL the requirements have been found.
17+# ZORBA_GENERATE_EXE_HELPERS_WIN32) when ALL the requirements have been found.
18 # E.g. zorba.exe needs in PATH all the DLLs of all external modules, etc.
19 IF (WIN32)
20 # Clear all the variables because they are used only for this build.
21@@ -166,10 +167,19 @@
22 SET (ZORBA_EXE_SCRIPT_LIST ""
23 CACHE STRING "List of Windows batch scripts to be generated, one for each executable" FORCE
24 )
25+ IF (MSVC_IDE)
26+ SET (ZORBA_VC_PROJECT_FILE_LIST ""
27+ CACHE STRING "List of Visual Studio project files to be generated, one for each executable" FORCE
28+ )
29+ ENDIF(MSVC_IDE)
30+
31 # Moreover, mark it as advanced since the CMake GUI user should not see this.
32 MARK_AS_ADVANCED (FORCE ZORBA_REQUIRED_DLLS)
33 MARK_AS_ADVANCED (FORCE ZORBA_REQUIRED_DLL_PATHS)
34 MARK_AS_ADVANCED (FORCE ZORBA_EXE_SCRIPT_LIST)
35+ IF (MSVC_IDE)
36+ MARK_AS_ADVANCED (FORCE ZORBA_VC_PROJECT_FILE_LIST)
37+ ENDIF(MSVC_IDE)
38 ENDIF (WIN32)
39 ################################################################################
40
41@@ -415,10 +425,11 @@
42 IF(WIN32)
43 SET(requiredlibs ${requiredlibs} wsock32)
44
45- # Clear this variable because this is used only for this build.
46+ # Clear those variables because this is used only for this build.
47 # A cache variable is needed since this must be modified by subdirectories
48- # and be visible at this level when ZORBA_GENERATE_EXE_SCRIPTS_WIN32 is called
49+ # and be visible at this level when ZORBA_GENERATE_EXE_HELPERS_WIN32 is called
50 SET(ZORBA_EXE_SCRIPT_LIST "" CACHE STRING "List of bat scripts" FORCE)
51+ SET(ZORBA_VC_PROJECT_FILE_LIST "" CACHE STRING "List of VC project files" FORCE)
52 ENDIF(WIN32)
53
54 ################################################################################
55@@ -568,7 +579,7 @@
56 ENDIF (APPLE AND UNIVERSAL)
57
58 IF (WIN32)
59- ZORBA_GENERATE_EXE_SCRIPTS_WIN32 ()
60+ ZORBA_GENERATE_EXE_HELPERS_WIN32 ()
61 ENDIF (WIN32)
62
63 # This must be done last! Create the one top-level target which
64
65=== modified file 'cmake_modules/ZorbaGenerateExe.cmake'
66--- cmake_modules/ZorbaGenerateExe.cmake 2012-05-03 12:31:51 +0000
67+++ cmake_modules/ZorbaGenerateExe.cmake 2012-06-14 12:20:25 +0000
68@@ -68,8 +68,8 @@
69 INSTALL (TARGETS ${EXE_NAME}${SUFFIX} DESTINATION ${INSTALL_DESTINATION})
70 ENDIF (NOT ${INSTALL_DESTINATION} STREQUAL "")
71
72- # generate list of bat scripts to set the PATH variable for the executables
73 IF (WIN32)
74+ # generate list of bat scripts to set the PATH variable for the executables
75 IF (NOT ${NEW_NAME} STREQUAL "")
76 SET (ZORBA_EXE_NAME "${NEW_NAME}${SUFFIX}")
77 ELSE (NOT ${NEW_NAME} STREQUAL "")
78@@ -79,20 +79,18 @@
79 SET (ZORBA_EXE_SCRIPT_LIST "${ZORBA_EXE_SCRIPT_LIST}${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_EXE_NAME}.bat;"
80 CACHE STRING "List of Windows batch scripts to be generated, one for each executable" FORCE
81 )
82+
83+
84+ # generate list of Visual Studio project files to set the PATH variable
85+ IF (MSVC_IDE)
86+ SET (SYSTEM_NAME $ENV{USERDOMAIN})
87+ SET (USER_NAME $ENV{USERNAME})
88+ SET (ZORBA_VC_PROJECT_FILE_LIST "${ZORBA_VC_PROJECT_FILE_LIST}${EXE_NAME}.vcproj.${SYSTEM_NAME}.${USER_NAME}.user"
89+ CACHE STRING "List of Visual Studio project files to be generated, one for each executable" FORCE
90+ )
91+ ENDIF (MSVC_IDE)
92 ENDIF (WIN32)
93
94- # generating initial property file for each executable in visual studio
95- # is done to set the PATH variable correctly
96- IF (MSVC_IDE)
97- SET (SYSTEM_NAME $ENV{USERDOMAIN})
98- SET (USER_NAME $ENV{USERNAME})
99- SET (ZORBA_VC_PROJECT_CONFIG_FILE "${EXE_NAME}${SUFFIX}.vcproj.${SYSTEM_NAME}.${USER_NAME}.user")
100- # Do not overwrite old property files. The user might have adapted something.
101- IF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_VC_PROJECT_CONFIG_FILE})
102- CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/cmake_modules/VCProject.vcproj.in ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_VC_PROJECT_CONFIG_FILE})
103- ENDIF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_VC_PROJECT_CONFIG_FILE})
104- ENDIF (MSVC_IDE)
105-
106 IF (ZORBA_BUILD_STATIC_LIBRARY)
107 ADD_EXECUTABLE ("${EXE_NAME}${SUFFIX}_static" ${SRCS})
108 SET_TARGET_PROPERTIES ("${EXE_NAME}${SUFFIX}_static" PROPERTIES COMPILE_DEFINITIONS BUILDING_ZORBA_STATIC)
109@@ -112,12 +110,12 @@
110 ENDMACRO (ZORBA_GENERATE_EXE)
111
112
113-# This macro will read the ZORBA_EXE_SCRIPT_LIST environments variable and will
114-# generate them near each corresponding executable.
115+# This macro will read the ZORBA_EXE_SCRIPT_LIST and ZORBA_VC_PROJECT_CONFIG_FILE
116+# environment variables and will generate them near each corresponding executable.
117 # This macro must be invoked AFTER all the required libraries have been searched
118 # for (both Zorba and external modules) in order to set a correct path in the
119 # scripts.
120-MACRO (ZORBA_GENERATE_EXE_SCRIPTS_WIN32)
121+MACRO (ZORBA_GENERATE_EXE_HELPERS_WIN32)
122
123 IF (NOT WIN32)
124 MESSAGE (FATAL_ERROR "This macro is intended only for Windows platforms.")
125@@ -141,4 +139,12 @@
126
127 ENDFOREACH (SCRIPT)
128
129-ENDMACRO (ZORBA_GENERATE_EXE_SCRIPTS_WIN32)
130+ FOREACH (VCFILE ${ZORBA_VC_PROJECT_FILE_LIST})
131+ # Do not overwrite old property files. The user might have adapted something.
132+ IF (NOT EXISTS ${VCFILE})
133+ CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/cmake_modules/VCProject.vcproj.in ${VCFILE})
134+ ENDIF (NOT EXISTS ${VCFILE})
135+ ENDFOREACH(VCFILE)
136+
137+
138+ENDMACRO (ZORBA_GENERATE_EXE_HELPERS_WIN32)

Subscribers

People subscribed via source and target branches