From: Geoff M. <ub...@ge...> - 2012-05-25 12:15:48
|
-Hi, Sorry I had not been following on the list, and thanks Dee for the direct tickle ;=)) I am still 'developing' full cmake understanding, so please correct me if I say something wrong about cmake... First the cmake library suffix has no effect on unix, and in this context, apple/MAC builds, so can be put for all... or in an if(WIN32 AND MSVC) context... And yes, I can understand that unix people do not get the difference, and WHY the big need in MSVC building ;=)) but please try to be 'tolerant' of the differences... And as someone pointed out I think, this suffix is NOT just for freeglut building, but if I am building a project using freeglut, then I might want to build both Release and Debug for that project... Because I want to Debug MY project... with source level debug view for ALL used 3rdparty libraries... Now, yes, when building my project I can point my project IDE to Release/freeglut.lib, and Debug/freeglut.lib resp., and not have a problem with the mixed CRT things... This is less of a problem with DLL/LIB, where actually the archive LIB part is the same, but IS a BIG problem with static links... read ERROR ;=(( But the usual thing is to 'install' freeglut into some 3rdParty/lib folder, and in this case the Debug MUST have a different name to the Release. Full stop! Regarding the idea of a catch-22 concerning the DEF file, well there are two ways to tell MSVC to build an archive library, LIB, as well as the DLL, and that is - 1. through a DEF file - the OLD way... or 2. through the MS specific __declspec pragma, one for building the library itself, dllexport, and one for importers/users of the library, dllimport. You do not need BOTH, and since you have the pragma, then the DEF file can be dropped. Or else you have to have 2 due to a change in library name in the head... or as you have found, just dropping the name from the DEF. There is another reason to use a DEF file, and that is to create 'alias' names for functions, and/or undecorated names, but I do not think you need, or use this alias, and already use extern "C" to get undecorated names, so again just drop the DEF! And this CMAKE_DEBUG_POSTFIX only effects the library. You need to do more to add the postfix to the demos, which I would suggest using... like set_target_properties( <project> PROPERTIES DEBUG_POSTFIX d ) Anyway, now to look at what has been changed so far... fresh svn co in another machine this time... (a) Ok you put the postfix in if(WIN32 AND MSVC) which is ok, but as indicated not really needed, since it has no effect on the SINGLE library generated in unix. (b) Next thing was to kill the .DEF file addition and generation... I note you already do this when building WIN64, so why keep it for WIN32... Well ok, I created an OPTION option(ADD_WIN32_DEF "Generate and link with a DEF file" OFF) in case 'someone' wants it ON, then twice IF(MSVC AND ADD_WIN32_DEF AND NOT CMAKE_CL_64) (c) Add the postfix for the demos. Luckily this is just one change to the ADD_DEMO MACRO ;=)) YOWEE, building the static and shared libraries went like a breeze ;=)) and got both the rel and the postfix 'd' version... 1 min 10 secs... BUT now note you install the DLL and its LIB in 3rdParty/lib... hmmm, it is more usual to install the LIB in lib, and the DLL in bin. Ah, there is is - you have - IF(BUILD_SHARED_LIBS) INSTALL(TARGETS freeglut DESTINATION lib) ENDIF() That should be - install( TARGETS freeglut RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) Now to enable demo building - 48 secs later - Ok, on the demos the postfix did not work. Not sure why... but maybe that is ok, because they are NOT installed...NO, that was my bad - just a spelling mistake ;=)) Fully trashed my out-of-source build directory, and start it all again - 1 min 53 secs, and I have everything ;=)) I use batch files, and an all command line build... No problems with the sinf - that seems fixed. multi-touch.c still reports 8 x C4113, and 2 x C4114 warnings... It is ok to 'know' that the C4113 given conversion from 'int' to 'float' will not be a problem... but you can also add -wd4113 to the MSVC compile flags and get rid of it. Or add a cast to tell the compiler 'you know' what you are doing ;=)) And the C4114 difference of () versus (void) could be fixed just by making the declaration the SAME as the function ;=)) Why not? Unfortunately out of time today so no time to try running all the demos... tried just bin\Release\shapes.exe bin\Debug\shapesd.exe and no problems with either... bin\Release\Fractals.exe - it ran, but reported ERROR opening file <fractals.dat> but sure that would be ok if I ran it in the folder where fractals.dat exists, or... As usual my current svn diff is attached. One small point, most projects are opting to use cmake lowercase directive while you have chosen uppercase... maybe it looks a little better in lowercase, but is a minor quibble ;=)) And this was all using MSVC10 PRO in Win 7 x64, but only tried the x86 (WIN32) lib versions... Will try to find time to do it all again with with x64, and with MSVC8, and maybe other MSVC versions next week. And YELL if I missed addressing some point, or you want expansion... and will try harder to better monitor this list ;=)) Regards, Geoff. <diff-02.txt> Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 1323) +++ CMakeLists.txt (working copy) @@ -28,6 +28,7 @@ OPTION(FREEGLUT_GLES1 "Use OpenGL ES 1.x (requires EGL)" OFF) OPTION(FREEGLUT_GLES2 "Use OpenGL ES 2.x (requires EGL) (overrides BUILD_GLES1)" OFF) +option(ADD_WIN32_DEF "Generate and link with a DEF file" OFF) SET(FREEGLUT_HEADERS include/GL/freeglut.h @@ -96,7 +97,7 @@ src/mswin/fg_window_mswin.c ${CMAKE_BINARY_DIR}/freeglut.rc # generated below from freeglut.rc.in ) - IF (MSVC AND NOT CMAKE_CL_64) + IF (MSVC AND ADD_WIN32_DEF AND NOT CMAKE_CL_64) # .def file only for 32bit Windows builds (TODO: MSVC only right # now, needed for any other Windows platform?) LIST(APPEND FREEGLUT_SRCS @@ -283,7 +284,7 @@ # we also have to generate freeglut.rc, which contains the version # number CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/freeglut.rc.in ${CMAKE_BINARY_DIR}/freeglut.rc) - IF (MSVC AND NOT CMAKE_CL_64) + IF (MSVC AND ADD_WIN32_DEF AND NOT CMAKE_CL_64) # .def file only for 32bit Windows builds with Visual Studio CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/freeglutdll.def.in ${CMAKE_BINARY_DIR}/freeglutdll.def) ENDIF() @@ -356,7 +357,10 @@ ENDIF() IF(BUILD_SHARED_LIBS) - INSTALL(TARGETS freeglut DESTINATION lib) + install(TARGETS freeglut + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ENDIF() IF(BUILD_STATIC_LIBS) INSTALL(TARGETS freeglut_static DESTINATION lib) @@ -385,6 +389,7 @@ TARGET_LINK_LIBRARIES(${name}_static ${DEMO_LIBS} freeglut_static) SET_TARGET_PROPERTIES(${name}_static PROPERTIES COMPILE_FLAGS -DFREEGLUT_STATIC) ENDIF() + set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d ) ENDIF() ENDMACRO() </diff-02.txt> |