diff --git a/CMakeLists.txt b/CMakeLists.txt index a5cf7ca77..56232eee5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,11 @@ PROJECT(speed-dreams-2) INCLUDE(cmake/macros.cmake) INCLUDE(cmake/checks.cmake) -# Pre-built 3rd Party under Windows. -IF(WIN32) +# Special 3rd Party handling for MS compilers. +IF(MSVC) INCLUDE(Find3rdPartyDependencies) -ENDIF(WIN32) + SD_FIND_3RDPARTY() +ENDIF(MSVC) CHECK_HEADERS_H() CHECK_FUNCTIONS() @@ -21,6 +22,7 @@ CHECK_PACKAGES() SET(NEXT_LESSER_VERSION 0) # The next lesser version SET(NEXT_MAJOR_MINOR_VERSION "2.1") # Next major.minor version +SET(OPTION_AUTOVERSION Off) IF(NOT OPTION_AUTOVERSION) SET(VERSION "${NEXT_MAJOR_MINOR_VERSION}-dev") @@ -124,27 +126,19 @@ ADD_SUBDIRECTORY(cmake) INSTALL_SD_CMAKE() # Generate a 'make clobber'-like clobber.sh/.bat script in case of an in-source build. -SD_GENERATE_CLOBBER_SCRIPT() +IF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + SD_GENERATE_CLOBBER_SCRIPT() +ENDIF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") # Add an unistall target. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY) -IF(WIN32) - ADD_CUSTOM_TARGET(UNINSTALL "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" ) -ELSE(WIN32) - ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" ) -ENDIF(WIN32) - -# Ensure system run-time libs are installed under Windows (MSVC*80.dll and co.). -# We do it ourselves, but use InstallRequiredSystemLibraries to figure out what they are -IF(WIN32) - SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) - INCLUDE(InstallRequiredSystemLibraries) - IF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) - INSTALL(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} - DESTINATION ${SD_BINDIR_ABS}) - ENDIF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) -ENDIF(WIN32) +IF(MSVC) + SET(_UNINST_TGT_NAME "UNINSTALL") +ELSE(MSVC) + SET(_UNINST_TGT_NAME "uninstall") +ENDIF(MSVC) +ADD_CUSTOM_TARGET(${_UNINST_TGT_NAME} "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" ) # Configure CPack. INCLUDE(cmake/packagemaker.cmake) diff --git a/INSTALL.txt b/INSTALL.txt index a5a00a75c..900bf0927 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -15,8 +15,9 @@ II - Linux Installation from sources III - Windows Installation from sources - 1 - CMake and MS VC++ 2005 (8) / 2008 (9) / 2010 (10) on Windows XP 32 - 2 - MS VC++ 6 no more supported + 1 - CMake and MinGW under Windows + 2 - CMake and MS VC++ 2005 (8) / 2008 (9) / 2010 (10) under Windows + 3 - MS VC++ 6 : no more supported IV - FreeBSD Installation from sources (Work in progress) @@ -34,14 +35,14 @@ I - Pre-requisites - OpenAL soft 1.5 / 1.6 / 1.11 / 1.14 (http://connect.creativelabs.com/openal) (Torcs modified 0.0.8 from www.torcs.org also used to work in the past). - ENet 1.3.2/4 (http://enet.bespin.org) - Linux: Be carefull to compile ENet with -fPIC on AMD64 if you run a 64 bit build. + Linux: Be careful to compile ENet with -fPIC on AMD64 if you run a 64 bit build. - Expat 2 (can be skipped for the moment, but won't anymore soon) - Free Solid 2 (optional for the moment, will soon get mandatory) - libpng - zlib - jpeg -WARNING: On Windows, be carefull to compile anything for multi-threaded DLL integration (/MD) +WARNING: Under Windows, be carefull to compile anything for multi-threaded DLL integration (/MD[d]) II - Linux installation from sources @@ -271,22 +272,123 @@ The Speed Dreams Team. II - Windows installation from sources --------------------------------------- -1) Cmake and MinGW : We want it ! Who can help us in this MinGW porting work :-? +Note that these instructions work under Windows XP 32 SP2/SP3 ; some tweaks wight be needed for newer / wider versions. + +0) Initial steps, common to all build methods + + a. Install CMake v2.6+ http://www.cmake.org/cmake/resources/software.html + b. Download the official Speed Dreams tarballs from SF.net + http://sourceforge.net/projects/speed-dreams/files/2.0.0 + (speed-dreams-src--.tar.xz) + Note: See below if you want to do it from SVN, in order to get the latest changes ... + c. Extract their contents to your local disk (7Zip is an excellent tool for that), + all in the same target folder. + Warning: You need to extract all of the source packages in order to start building + (see ablove 2-a chapter for more). + +1) Cmake and MinGW : + + Work-in-progress ... + + Tested with success for : + - CMake 2.8.3 + MinGW shipped with Nokia Qt Creator 2.4.1 (gcc 4.4.0) + - CMake 2.8.8 + MinGW shipped with Nokia Qt Creator 2.4.1 (gcc 4.4.0) + - CMake 2.8.2 + MinGW 2012 April (gcc 4.7.0) + - CMake 2.8.8 + MinGW 2012 April (gcc 4.7.0) + + d. Install MinGW and MSYS + + Following the instructions of http://www.mingw.org/wiki/Getting_Started + (example here for the official release of 2012, April, featuring gcc 4.7.0) : + + * Download and run the latest mingw-get-inst version from + https://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/ + => mingw-get-inst-20120426.exe + * Select the directory where to install MinGW, remembering the advice + that the path to this directory should not contain any spaces. + => C:\MinGW + * Select the minimal set of components to install : + * C++ compiler + * MSYS. + + * Run MSYS, the MinGW Shell (bash) : + Start Menu / Programs / MinGW / MinGW Shell + + Note: PATH is already configured for using all useful tools + (try the command "echo $PATH") + + * Optional but usefull additional components : + * rxvt (a Linux-like terminal) : mingw-get install msys-rxvt + - customize rxvt terminal : in C:\MinGW\MSYS\1.0\msys.bat, line 98 : "start %WD%rxvt ...", + . -geometry 120x40 + . -sl 9999 + - change MSYS Shell shortcut command : msys.bat --rxvt + * vim (text editor for Linux geeks) : mingw-get install msys-vim + * patch : mingw-get install msys-patch + * xargs and co : mingw-get install msys-findutils + * bzip2 : mingw-get install msys-bzip2 + * xz : mingw-get install msys-xz + * diff and co : mingw-get install msys-diffutils + + * Optional tweaks to /etc/profile (C:\MinGW\msys\1.0\etc\profile) + * add your usual aliases : alias xx='command' + * a nicer prompt : export PS1='\w $ ' + + * Direct X 7 SDK for MinGW : Optional for building SD, but mandatory if you want + to build yourself the 3rd party libraries SDL, PLib, and OpenAL : + * download it from http://alleg.sourceforge.net/files/dx70_min.zip + * extract it somewhere on your hard disk (let's say C:\dx7_mingw) + * add the following line to /etc/fstab (C:\MinGW\msys\1.0\etc\fstab) + C:\dx7_mingw /dxsdk # DX7 SDK for compiling SDL, PLib, OpenAL + + Note: The other newer versions from http://alleg.sourceforge.net/files didn't work for me. + + Another solution (tested with success) : + * MinGW itself : You can use the one shipped with Nokia Qt Creator + (Release 2.4.1 worked for me) + * MSYS : + - download and install the latest 1.0.x through the MinGW installer + https://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/ + - add a /mingw mount point to the fstab in order MSYS knows where MinGW is installed + (inside Qt Creator folders) : + ex: add a "c:/Qt/qtcreator-2.4.1/mingw /mingw" line to /etc/fstab + * Qt creator is a full-fledged IDE, making you able to : + - open your SD "project" (equivalent to a MSVC "solution") + by simply opening the master CMakeLists.txt in Qt Creator, + - run CMake after specifying the needed options (see below), + - make and install SD, + - and everything you expect from a modern IDE (MSVC 2005 is not one ;-) + all of the above through the GUI. + * But you'll have to build yourself your 3rd party package for this (older) GCC version + + Last minute news : It seems that Nokia no more ships MinGW with it's QtCreator IDE, + but let you use the one you like ... see Nokia's HOWTO pages. + + e. Download the "MinGW 4.7.0" release of the Speed Dreams "3rdParty" binary package from SF.net + http://sourceforge.net/projects/speed-dreams/files/3rd%20party + (it contains necessary 3rd party libs compiled with/for MinGW 4.7.0) + + f. Extract it to the /usr/local folder : + From the MinGW Shell : + $ cd /usr + $ tar xvfz .../3rdParty-2.1-win32-mingw470-g-O2.tar.gz + + g. Run CMake to configure the build (here we assume CMake 2.8, but newer versions should work) : + + $ cd /path/to/sd/sources/trunk + $ mkdir build + $ cd build + $ /c/Program\ Files/CMake\ 2.8/bin/cmake -G "MSYS Makefiles" -DOPTION_OFFICIAL_ONLY:BOOL=On -DCMAKE_PREFIX_PATH:STRING=/usr/local -DCMAKE_BUILD_TYPE:STRING=Release .. + $ make # -j2 or even -j4 if you own a dual/quad-core CPU + $ make install + + Note: This 'Release' build gives you -O3-optimised binaries. 2) Cmake and MS VC++ 2005 (8) / 2008 (9) / 2010 (10) on Windows XP 32 Note: If you use an "Express" version, don't forget to install also the Windows SDK. - a. Install CMake v2.6+ http://www.cmake.org/cmake/resources/software.html - b. Download the official tarballs from SF.net - http://sourceforge.net/projects/speed-dreams/files/2.0.0 - (speed-dreams-src--.tar.xz) - Note: See below if you want to do it from SVN ... - c. Extract their contents to your local disk (7Zip is an excellent tool for that), - all in the same target folder. - Warning: You need to extract all of the source packages in order to start building - (see ablove 2-a chapter for more). - d. Download the "MSVC 2005 / 2.0.0-or-earlier" release of the "3rdParty" package on SF.net + d. Download the "MSVC 2005 / 2.0.0-or-earlier" release of the "3rdParty" binary package from SF.net http://sourceforge.net/projects/speed-dreams/files/3rd%20party (it contains necessary 3rd party libs compiled with/for MSVC 2005) e. Extract from the zip file the "3rdParty" directory to where speed-dreams sources diff --git a/cmake/Find3rdPartyDependencies.cmake b/cmake/Find3rdPartyDependencies.cmake index bf0cb93f0..32f66698d 100644 --- a/cmake/Find3rdPartyDependencies.cmake +++ b/cmake/Find3rdPartyDependencies.cmake @@ -1,9 +1,8 @@ ################################################################################################ # Find a generic dependency, handling debug suffix # all the parameters are required ; in case of lists or empty parameter, use "" when calling -################################################################################################ -MACRO(FIND_DEPENDENCY DEP_NAME INCLUDE_FILE INCLUDE_SUBDIRS LIBRARY_NAMES SEARCH_PATH_LIST DEBUG_SUFFIX) +MACRO(_FIND_3RDPARTY_DEPENDENCY DEP_NAME INCLUDE_FILE INCLUDE_SUBDIRS LIBRARY_NAMES SEARCH_PATH_LIST DEBUG_SUFFIX) #MESSAGE(STATUS "Searching for 3rd party dependency DEP_NAME='${DEP_NAME}' INCLUDE_FILE='${INCLUDE_FILE}' INCLUDE_SUBDIRS='${INCLUDE_SUBDIRS}' LIBRARY_NAMES='${LIBRARY_NAMES}' SEARCH_PATH_LIST='${SEARCH_PATH_LIST}' DEBUG_SUFFIX='${DEBUG_SUFFIX}' ...") @@ -35,7 +34,7 @@ MACRO(FIND_DEPENDENCY DEP_NAME INCLUDE_FILE INCLUDE_SUBDIRS LIBRARY_NAMES SEARCH NO_DEFAULT_PATH ) MARK_AS_ADVANCED("${DEP_NAME}_INCLUDE_DIR") - #MESSAGE(" ${DEP_NAME}_INCLUDE_DIR = '${${DEP_NAME}_INCLUDE_DIR}'") + #MESSAGE(STATUS " ${DEP_NAME}_INCLUDE_DIR = '${${DEP_NAME}_INCLUDE_DIR}'") # Find library files SET(MY_PATH_LIB ) @@ -43,13 +42,14 @@ MACRO(FIND_DEPENDENCY DEP_NAME INCLUDE_FILE INCLUDE_SUBDIRS LIBRARY_NAMES SEARCH SET(MY_PATH_LIB ${MY_PATH_LIB} ${MY_PATH}/lib) ENDFOREACH(MY_PATH ${SEARCH_PATH_LIST} ) + #MESSAGE(STATUS "LIBRARY_NAMES='${LIBRARY_NAMES}', MY_PATH_LIB=${MY_PATH_LIB}") FIND_LIBRARY("${DEP_NAME}_LIBRARY" NAMES ${LIBRARY_NAMES} PATHS ${MY_PATH_LIB} NO_DEFAULT_PATH ) MARK_AS_ADVANCED("${DEP_NAME}_LIBRARY") - #MESSAGE(" ${DEP_NAME}_LIBRARY = '${${DEP_NAME}_LIBRARY}'") + #MESSAGE(STATUS " ${DEP_NAME}_LIBRARY = '${${DEP_NAME}_LIBRARY}'") # Whatever happened, done. SET(${DEP_NAME}_FOUND "NO" ) @@ -57,28 +57,24 @@ MACRO(FIND_DEPENDENCY DEP_NAME INCLUDE_FILE INCLUDE_SUBDIRS LIBRARY_NAMES SEARCH SET( ${DEP_NAME}_FOUND "YES" ) ENDIF(${DEP_NAME}_INCLUDE_DIR AND ${DEP_NAME}_LIBRARY) -ENDMACRO(FIND_DEPENDENCY DEP_NAME INCLUDE_FILE INCLUDE_SUBDIRS LIBRARY_NAMES SEARCH_PATH_LIST DEBUG_SUFFIX) +ENDMACRO(_FIND_3RDPARTY_DEPENDENCY DEP_NAME INCLUDE_FILE INCLUDE_SUBDIRS LIBRARY_NAMES SEARCH_PATH_LIST DEBUG_SUFFIX) -################################################################################################ -# this Macro is tailored to Mike dependencies -################################################################################################ +MACRO(_FIND_3RDPARTY_DEPENDENCIES ROOT_DIR) -MACRO(SEARCH_3RDPARTY ROOT_DIR) - - FIND_DEPENDENCY(SDL sdl.h "SDL;SDL2" sdl "${ROOT_DIR}" "") - FIND_DEPENDENCY(SDLMAIN sdl_main.h "SDL;SDL2" sdlmain "${ROOT_DIR}" "") + _FIND_3RDPARTY_DEPENDENCY(SDL sdl.h "SDL;SDL2" sdl "${ROOT_DIR}" "") + _FIND_3RDPARTY_DEPENDENCY(SDLMAIN sdl_main.h "SDL;SDL2" sdlmain "${ROOT_DIR}" "") IF(SDL_FOUND) # Dirty hack to make FindPackage(SDL) work later. SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY} CACHE FILEPATH "") ENDIF(SDL_FOUND) - FIND_DEPENDENCY(PLIB plib/sg.h "" sg ${ROOT_DIR} "") - FIND_DEPENDENCY(PLIB_SSG plib/ssg.h "" ssg ${ROOT_DIR} "") - FIND_DEPENDENCY(PLIB_SG plib/sg.h "" sg ${ROOT_DIR} "") - FIND_DEPENDENCY(PLIB_SL plib/sl.h "" sl ${ROOT_DIR} "") - FIND_DEPENDENCY(PLIB_SSGAUX plib/ssgaux.h "" ssgaux ${ROOT_DIR} "") - FIND_DEPENDENCY(PLIB_UL plib/ul.h "" ul ${ROOT_DIR} "") - FIND_DEPENDENCY(PLIB_JS plib/js.h "" js ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(PLIB plib/sg.h "" sg ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(PLIB_SSG plib/ssg.h "" ssg ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(PLIB_SG plib/sg.h "" sg ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(PLIB_SL plib/sl.h "" sl ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(PLIB_SSGAUX plib/ssgaux.h "" ssgaux ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(PLIB_UL plib/ul.h "" ul ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(PLIB_JS plib/js.h "" js ${ROOT_DIR} "") # Note: The Open GL includes are automatically added by MSVC 2005. # We simply add here the include path for the Open GL extensions headers, @@ -87,19 +83,19 @@ MACRO(SEARCH_3RDPARTY ROOT_DIR) Find_Package(OpenGL) FIND_PATH(OPENGL_INCLUDE_DIR GL/glext.h ${ROOT_DIR}/include NO_DEFAULT_PATH) - FIND_DEPENDENCY(OPENAL AL/al.h "" openal32 ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(OPENAL AL/al.h "" openal32 ${ROOT_DIR} "") - FIND_DEPENDENCY(ENET enet/enet.h "" enet ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(ENET enet/enet.h "" enet ${ROOT_DIR} "") IF(OPTION_3RDPARTY_EXPAT) - FIND_DEPENDENCY(EXPAT expat.h "" expat ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(EXPAT expat.h "" expat ${ROOT_DIR} "") ENDIF(OPTION_3RDPARTY_EXPAT) IF(OPTION_3RDPARTY_SOLID) - FIND_DEPENDENCY(SOLID SOLID/solid.h "" "solid;broad" ${ROOT_DIR} "") - FIND_DEPENDENCY(SOLID_SOLID SOLID/solid.h "" "solid" ${ROOT_DIR} "") - FIND_DEPENDENCY(SOLID_BROAD SOLID/broad.h "" "broad" ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(SOLID SOLID/solid.h "" "solid;broad" ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(SOLID_SOLID SOLID/solid.h "" "solid" ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(SOLID_BROAD SOLID/broad.h "" "broad" ${ROOT_DIR} "") IF(SOLID_FOUND) # Force subsequent FindSOLID stuff not to search for other variables ... kind of a hack @@ -109,13 +105,13 @@ MACRO(SEARCH_3RDPARTY ROOT_DIR) ENDIF(OPTION_3RDPARTY_SOLID) - FIND_DEPENDENCY(JPEG jpeglib.h "" jpeg_s ${ROOT_DIR} "") + _FIND_3RDPARTY_DEPENDENCY(JPEG jpeglib.h "" jpeg_s ${ROOT_DIR} "") - FIND_DEPENDENCY(ZLIB zlib.h "" "z;zlib;zlib1" ${ROOT_DIR} "D") + _FIND_3RDPARTY_DEPENDENCY(ZLIB zlib.h "" "z;zlib;zlib1" ${ROOT_DIR} "D") IF(ZLIB_FOUND) - FIND_DEPENDENCY(PNG png.h "" "libpng;libpng13;libpng14;libpng15;libpng16" ${ROOT_DIR} "D") + _FIND_3RDPARTY_DEPENDENCY(PNG png.h "" "libpng;libpng13;libpng14;libpng15;libpng16" ${ROOT_DIR} "D") IF(PNG_FOUND) # Force subsequent FindPNG stuff not to search for other variables ... kind of a hack @@ -125,26 +121,126 @@ MACRO(SEARCH_3RDPARTY ROOT_DIR) ENDIF(ZLIB_FOUND) -ENDMACRO(SEARCH_3RDPARTY ROOT_DIR) +ENDMACRO(_FIND_3RDPARTY_DEPENDENCIES ROOT_DIR) ################################################################################################ -# this is code for handling optional 3DPARTY usage (mainly under Windows) +# Handling of optional 3rd party package (usefull only when building under Windows with MSVC) + +MACRO(SD_FIND_3RDPARTY) + + OPTION(SDEXT_USE_CUSTOM_3DPARTY "Set to ON to use 3rdParty prebuilt API located in /../3rdparty" ON) + MARK_AS_ADVANCED(SDEXT_USE_CUSTOM_3DPARTY) + + IF(SDEXT_USE_CUSTOM_3DPARTY) + + GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH) + SET(SDEXT_CUSTOM_3DPARTY_DIR "${PARENT_DIR}/3rdparty" CACHE PATH + "Location of 3rdParty dependencies") + IF(EXISTS ${SDEXT_CUSTOM_3DPARTY_DIR}) + _FIND_3RDPARTY_DEPENDENCIES(${SDEXT_CUSTOM_3DPARTY_DIR}) + ENDIF(EXISTS ${SDEXT_CUSTOM_3DPARTY_DIR}) + + MARK_AS_ADVANCED(SDEXT_CUSTOM_3DPARTY_DIR) + + ENDIF(SDEXT_USE_CUSTOM_3DPARTY) + +ENDMACRO(SD_FIND_3RDPARTY) + ################################################################################################ +# Under Windows, install needed 3rd party DLLs close to Speed Dreams executable +# (but stay compatible with the old 2.0.0 3rd party package which had less DLLs inside) -OPTION(SDEXT_USE_CUSTOM_3DPARTY "Set to ON to use 3rdParty prebuilt API located in /../3rdparty" ON) -MARK_AS_ADVANCED(SDEXT_USE_CUSTOM_3DPARTY) +MACRO(_FIND_3RDPARTY_DLL PACKAGE_NAME LINK_LIBRARY NAME_HINTS DLL_PATHNAME_VAR) -IF(SDEXT_USE_CUSTOM_3DPARTY) + FIND_PACKAGE(${PACKAGE_NAME}) - GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH) - SET(SDEXT_CUSTOM_3DPARTY_DIR "${PARENT_DIR}/3rdparty" CACHE PATH - "Location of 3rdParty dependencies") - IF(EXISTS ${SDEXT_CUSTOM_3DPARTY_DIR}) - SEARCH_3RDPARTY(${SDEXT_CUSTOM_3DPARTY_DIR}) - ENDIF(EXISTS ${SDEXT_CUSTOM_3DPARTY_DIR}) + FOREACH(_LIB_NAME ${NAME_HINTS}) - # Not very useful if not Windows. - IF(NOT WIN32) - MARK_AS_ADVANCED(SDEXT_CUSTOM_3DPARTY_DIR) - ENDIF(NOT WIN32) -ENDIF(SDEXT_USE_CUSTOM_3DPARTY) + # Must handle the case of multiple libs listed in ${LINK_LIBRARY} + SET(_LIB_PATHNAME ${LINK_LIBRARY}) + FOREACH(_LIB_PATHNAME_ ${LINK_LIBRARY}) + IF(${_LIB_PATHNAME_} MATCHES "${_LIB_NAME}\\.") + SET(_LIB_PATHNAME ${_LIB_PATHNAME_}) + BREAK() + ENDIF(${_LIB_PATHNAME_} MATCHES "${_LIB_NAME}\\.") + ENDFOREACH(_LIB_PATHNAME_ ${LINK_LIBRARY}) + + # Got 1 link library pathname : check if any corresponding DLL around. + GET_FILENAME_COMPONENT(_LIB_PATH "${_LIB_PATHNAME}" PATH) + SET(${DLL_PATHNAME_VAR} "${_LIB_PATH}/../bin/${_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") + #MESSAGE(STATUS "Trying 3rdParty DLL ${${DLL_PATHNAME_VAR}} for ${PACKAGE_NAME}") + IF(NOT EXISTS "${${DLL_PATHNAME_VAR}}") + SET(_LIB_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}${_LIB_NAME}") + SET(${DLL_PATHNAME_VAR} "${_LIB_PATH}/../bin/${_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") + #MESSAGE(STATUS "Trying 3rdParty DLL ${${DLL_PATHNAME_VAR}} for ${PACKAGE_NAME}") + ENDIF(NOT EXISTS "${${DLL_PATHNAME_VAR}}") + #MESSAGE(STATUS "XX ${${DLL_PATHNAME_VAR}} <= ${LINK_LIBRARY} : ${_LIB_NAME} in ${_LIB_PATH}") + IF(EXISTS "${${DLL_PATHNAME_VAR}}") + #MESSAGE(STATUS "Found 3rdParty DLL ${${DLL_PATHNAME_VAR}} for ${PACKAGE_NAME}") + BREAK() + ELSE(EXISTS "${${DLL_PATHNAME_VAR}}") + UNSET(${DLL_PATHNAME_VAR}) + ENDIF(EXISTS "${${DLL_PATHNAME_VAR}}") + + ENDFOREACH(_LIB_NAME ${NAME_HINTS}) + + IF(NOT ${_DLL_PATHNAME_VAR}) + #MESSAGE(STATUS "Could not find 3rdParty DLL in ${NAME_HINTS} for ${PACKAGE_NAME}") + ENDIF(NOT ${_DLL_PATHNAME_VAR}) + +ENDMACRO(_FIND_3RDPARTY_DLL DLL_PATHNAME) + +MACRO(SD_INSTALL_3RDPARTY) + + SET(_THIRDPARTY_DLL_PATHNAMES) + + _FIND_3RDPARTY_DLL("OpenAL" "${OPENAL_LIBRARY}" "OpenAL32" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + _FIND_3RDPARTY_DLL("SDL" "${SDL_LIBRARY}" "SDL" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + IF(OPTION_3RDPARTY_EXPAT) + + _FIND_3RDPARTY_DLL("EXPAT" "${EXPAT_LIBRARY}" "expat;expat-1" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + ENDIF(OPTION_3RDPARTY_EXPAT) + + IF(OPTION_3RDPARTY_SOLID) + + _FIND_3RDPARTY_DLL("SOLID" "${SOLID_SOLID_LIBRARY}" "solid" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + _FIND_3RDPARTY_DLL("SOLID" "${SOLID_BROAD_LIBRARY}" "broad" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + ENDIF(OPTION_3RDPARTY_SOLID) + + _FIND_3RDPARTY_DLL("ZLIB" "${ZLIB_LIBRARY}" "zlib" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + _FIND_3RDPARTY_DLL("PNG" "${PNG_LIBRARY}" "png" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + _FIND_3RDPARTY_DLL("JPEG" "${JPEG_LIBRARY}" "jpeg-8" _DLL_PATHNAME) + LIST(APPEND _THIRDPARTY_DLL_PATHNAMES "${_DLL_PATHNAME}") + + #MESSAGE(STATUS "3rdParty dependencies : Will install ${_THIRDPARTY_DLL_PATHNAMES}") + SD_INSTALL_FILES(BIN FILES ${_THIRDPARTY_DLL_PATHNAMES}) + + # Make sure Windows compilers run-time libs are also installed. + IF(MSVC) + # We do it ourselves, but use InstallRequiredSystemLibraries to figure out what they are + SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) + INCLUDE(InstallRequiredSystemLibraries) + IF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) + SD_INSTALL_FILES(BIN FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}) + ENDIF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) + ELSEIF(MINGW) + # Works with MinGW 4.4 and 4.7. + GET_FILENAME_COMPONENT(_MINGW_BINDIR "${CMAKE_CXX_COMPILER}" PATH) + SD_INSTALL_FILES(BIN FILES "${_MINGW_BINDIR}/libstdc++-6.dll" "${_MINGW_BINDIR}/libgcc_s_dw2-1.dll") + ENDIF(MSVC) + +ENDMACRO(SD_INSTALL_3RDPARTY) diff --git a/cmake/checks.cmake b/cmake/checks.cmake index 7ece2aadb..2fe5151b4 100644 --- a/cmake/checks.cmake +++ b/cmake/checks.cmake @@ -23,14 +23,20 @@ ENDMACRO(CHECK_HEADERS_H) MACRO(CHECK_FUNCTIONS) CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP) + CHECK_FUNCTION_EXISTS(strtok_r HAVE_STRTOK_R) + IF(MSVC) + CHECK_FUNCTION_EXISTS(_isnan HAVE_ISNAN) + ELSE(MSVC) + CHECK_FUNCTION_EXISTS(isnan HAVE_ISNAN) + ENDIF(MSVC) ENDMACRO(CHECK_FUNCTIONS) MACRO(CHECK_LIBRARIES) - IF (UNIX) + IF(UNIX) - FIND_PACKAGE(X11) + FIND_PACKAGE(X11) CHECK_LIBRARY_EXISTS(m sin "" HAVE_LIBM) CHECK_LIBRARY_EXISTS(Xext XShmCreateImage "${X11_LIBRARY_DIR}" HAVE_LIBXEXT) @@ -170,6 +176,15 @@ MACRO(CHECK_PACKAGES) MESSAGE(STATUS "Looking for library PNG - NOT found") ENDIF(PNG_FOUND) + Find_Package(JPEG) + + IF(JPEG_FOUND) + SET(HAVE_LIBJPEG 1) + MESSAGE(STATUS "Looking for library JPEG - found") + ELSE(JPEG_FOUND) + MESSAGE(STATUS "Looking for library JPEG - NOT found") + ENDIF(JPEG_FOUND) + Find_Package(SDL) IF(SDL_FOUND) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 26528c410..71f4537d8 100755 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -91,6 +91,12 @@ /* Define to 1 if you have the `strndup' function. */ #cmakedefine HAVE_STRNDUP 1 +/* Define to 1 if you have the `strtok_r' function. */ +#cmakedefine HAVE_STRTOK_R 1 + +/* Define to 1 if you have the `isnan' function. */ +#cmakedefine HAVE_ISNAN 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_STAT_H 1 diff --git a/cmake/macros.cmake b/cmake/macros.cmake index 667b0f088..f24ff17a6 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -200,6 +200,7 @@ MACRO(GENERATE_ROBOT_DEF_FILE ROBOTNAME DEF_FILE) ENDFOREACH(SYMBOL ${SYMBOLS}) # Generate the .def file + SET(ROBOT_NAME "${ROBOTNAME}") IF(IN_SOURCETREE) CONFIGURE_FILE(${SOURCE_DIR}/cmake/robot_def.cmake ${DEF_FILE}) ELSE(IN_SOURCETREE) @@ -259,15 +260,15 @@ MACRO(ROBOT_MODULE) ADD_SDLIB_INCLUDEDIR(learning math portability robottools tgf) ADD_PLIB_INCLUDEDIR() - # Generate / add .def file for Windows - IF(WIN32) + # Generate / add .def file for MSVC compilers. + IF(MSVC) IF(NOT RBM_HAS_INTERFACE OR NOT RBM_INTERFACE) SET(RBM_INTERFACE "LEGACY_MIN") ENDIF() SET(ROBOT_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/${RBM_NAME}_gen.def) GENERATE_ROBOT_DEF_FILE(${RBM_NAME} ${ROBOT_DEF_FILE} ${RBM_INTERFACE}) SET(RBM_SOURCES ${RBM_SOURCES} ${ROBOT_DEF_FILE}) - ENDIF(WIN32) + ENDIF(MSVC) # Disable developer warning IF (COMMAND cmake_policy) @@ -283,8 +284,11 @@ MACRO(ROBOT_MODULE) ADD_LIBRARY(${RBM_NAME} SHARED ${RBM_SOURCES}) # Customize shared library versions and file prefix. - IF(UNIX) # Use ldconfig version naming scheme + no "lib" prefix under Linux + IF(UNIX OR MINGW) # No "lib" prefix under Linux / MinGW SET_TARGET_PROPERTIES(${RBM_NAME} PROPERTIES PREFIX "") + ENDIF() + + IF(UNIX) # Use ldconfig version naming scheme + no "lib" prefix under Linux # Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose) #SET_TARGET_PROPERTIES(${RBM_NAME} PROPERTIES VERSION ${RBM_VERSION}) #SET_TARGET_PROPERTIES(${RBM_NAME} PROPERTIES SOVERSION ${RBM_SOVERSION}) @@ -763,6 +767,9 @@ MACRO(ADD_PLIB_LIBRARY TARGET) FOREACH(PLIB_LIB ${ARGN}) IF(PLIB_LIB STREQUAL "ul") SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_UL_LIBRARY}) + IF(MINGW) # winmm must _follow_ ul in the linker command line (otherwise _timeGetTime undefined). + SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} winmm) + ENDIF(MINGW) ELSEIF(PLIB_LIB STREQUAL "js") SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_JS_LIBRARY}) ELSEIF(PLIB_LIB STREQUAL "sg") @@ -1007,7 +1014,6 @@ MACRO(ADD_X11_INCLUDEDIR) IF(X11_FOUND) INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR}) - MESSAGE(STATUS "INCLUDED ${X11_INCLUDE_DIR}") ELSE(X11_FOUND) MESSAGE(FATAL_ERROR "Cannot find X11 header files") ENDIF(X11_FOUND) @@ -1112,13 +1118,13 @@ MACRO(ADD_SD_COMPILE_OPTIONS) SET(OPTION_3RDPARTY_EXPAT true CACHE BOOL "Use 3rd party Expat library rather than bundled TXML") - # Enable building with 3rd party SOLID library with MSVC, as we ship the binary package, + # Enable building with 3rd party SOLID library under Windows, as we ship the binary package, # but not under Linux, where FreeSolid seems not to be available by default on most distros. - IF(MSVC) + IF(WIN32) SET(_OPTION_3RDPARTY_SOLID true) - ELSE(MSVC) + ELSE(WIN32) SET(_OPTION_3RDPARTY_SOLID false) - ENDIF(MSVC) + ENDIF(WIN32) SET(OPTION_3RDPARTY_SOLID ${_OPTION_3RDPARTY_SOLID} CACHE BOOL "Use 3rd party SOLID library rather than simu-bundled one") IF(UNIX) @@ -1370,22 +1376,22 @@ MACRO(SD_INSTALL_FILES) ENDIF() # Execute xmlversion at install-time to do this registration job. - IF(WIN32) + GET_TARGET_PROPERTY(TGF_LIB tgf LOCATION) + IF(MSVC) - # Under Windows, in order to run xmlversion.exe in the build tree, - # we have to copy dependencies next to it (txml or Expat, and SDL). + # When building with MSVC, in order to run xmlversion.exe in the build tree, + # we have to copy all dependencies next to it (tgf, txml or Expat, and SDL). IF(NOT OPTION_3RDPARTY_EXPAT) GET_TARGET_PROPERTY(TXML_LIB txml LOCATION) ELSE(NOT OPTION_3RDPARTY_EXPAT) FIND_PACKAGE(EXPAT) - GET_FILENAME_COMPONENT(EXPAT_LIBPATH ${EXPAT_LIBRARY} PATH) - GET_FILENAME_COMPONENT(EXPAT_LIBNAME ${EXPAT_LIBRARY} NAME_WE) + GET_FILENAME_COMPONENT(EXPAT_LIBPATH "${EXPAT_LIBRARY}" PATH) + GET_FILENAME_COMPONENT(EXPAT_LIBNAME "${EXPAT_LIBRARY}" NAME_WE) SET(EXPAT_LIB ${EXPAT_LIBPATH}/../bin/${CMAKE_SHARED_LIBRARY_PREFIX}${EXPAT_LIBNAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) ENDIF(NOT OPTION_3RDPARTY_EXPAT) - GET_TARGET_PROPERTY(TGF_LIB tgf LOCATION) FIND_PACKAGE(SDL) - GET_FILENAME_COMPONENT(SDL_LIBPATH ${SDL_LIBRARY} PATH) - GET_FILENAME_COMPONENT(SDL_LIBNAME ${SDL_LIBRARY} NAME_WE) + GET_FILENAME_COMPONENT(SDL_LIBPATH "${SDL_LIBRARY}" PATH) + GET_FILENAME_COMPONENT(SDL_LIBNAME "${SDL_LIBRARY}" NAME_WE) SET(SDL_LIB ${SDL_LIBPATH}/../bin/${CMAKE_SHARED_LIBRARY_PREFIX}${SDL_LIBNAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) INSTALL(CODE @@ -1423,10 +1429,18 @@ MACRO(SD_INSTALL_FILES) ENDIF() ENDFOREACH()") - ELSE(WIN32) + ELSE(MSVC) - INSTALL(CODE + INSTALL(CODE "FILE(READ ${CMAKE_BINARY_DIR}/xmlversion_loc.txt XMLVERSION_EXE) + GET_FILENAME_COMPONENT(XMLVERSION_DIR \${XMLVERSION_EXE} PATH) + SET(MINGW ${MINGW}) + IF(MINGW) + # When building with MinGW, in order to run xmlversion.exe in the build tree, + # we have to copy internal dependencies next to it (tgf). + SET(TGF_LIB ${TGF_LIB}) + FILE(INSTALL DESTINATION \${XMLVERSION_DIR} TYPE FILE FILES \${TGF_LIB}) + ENDIF(MINGW) SET(SD_DATADIR_ABS \"${SD_DATADIR}\") IF(NOT IS_ABSOLUTE \${SD_DATADIR_ABS}) GET_FILENAME_COMPONENT(SD_DATADIR_ABS \"\${CMAKE_INSTALL_PREFIX}/\${SD_DATADIR_ABS}\" ABSOLUTE) @@ -1442,11 +1456,11 @@ MACRO(SD_INSTALL_FILES) GET_FILENAME_COMPONENT(FILENAME \${FILE} NAME) EXECUTE_PROCESS(COMMAND \"\${XMLVERSION_EXE}\" \"\${CUR_DESTDIR_CORR}\${SD_DATADIR_ABS}/version.xml\" \"${DATA_PATH}\${FILENAME}\" \"${USER_PATH}/\${FILENAME}\" \"\${CUR_DESTDIR_CORR}\${SD_DATADIR_ABS}\" RESULT_VARIABLE XMLVERSTATUS) IF(XMLVERSTATUS) - MESSAGE(FATAL_ERROR \"Error: xmlversion failed\") + MESSAGE(FATAL_ERROR \"Error: xmlversion failed \$ENV(PATH)\") ENDIF(XMLVERSTATUS) ENDFOREACH()") - ENDIF(WIN32) + ENDIF(MSVC) ENDIF(IS_USER) @@ -1542,22 +1556,22 @@ MACRO(SD_INSTALL_DIRECTORIES) ENDIF() # Execute xmlversion at install-time to do this registration job. - IF(WIN32) + IF(MSVC) - # Under Windows, in order to run xmlversion.exe in the build tree, + # When building with MSVC, in order to run xmlversion.exe in the build tree, # we have to copy dependencies next to it (txml or Expat, and SDL). IF(NOT OPTION_3RDPARTY_EXPAT) GET_TARGET_PROPERTY(TXML_LIB txml LOCATION) ELSE(NOT OPTION_3RDPARTY_EXPAT) FIND_PACKAGE(EXPAT) - GET_FILENAME_COMPONENT(EXPAT_LIBPATH ${EXPAT_LIBRARY} PATH) - GET_FILENAME_COMPONENT(EXPAT_LIBNAME ${EXPAT_LIBRARY} NAME_WE) + GET_FILENAME_COMPONENT(EXPAT_LIBPATH "${EXPAT_LIBRARY}" PATH) + GET_FILENAME_COMPONENT(EXPAT_LIBNAME "${EXPAT_LIBRARY}" NAME_WE) SET(EXPAT_LIB ${EXPAT_LIBPATH}/../bin/${CMAKE_SHARED_LIBRARY_PREFIX}${EXPAT_LIBNAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) ENDIF(NOT OPTION_3RDPARTY_EXPAT) GET_TARGET_PROPERTY(TGF_LIB tgf LOCATION) FIND_PACKAGE(SDL) - GET_FILENAME_COMPONENT(SDL_LIBPATH ${SDL_LIBRARY} PATH) - GET_FILENAME_COMPONENT(SDL_LIBNAME ${SDL_LIBRARY} NAME_WE) + GET_FILENAME_COMPONENT(SDL_LIBPATH "${SDL_LIBRARY}" PATH) + GET_FILENAME_COMPONENT(SDL_LIBNAME "${SDL_LIBRARY}" NAME_WE) SET(SDL_LIB ${SDL_LIBPATH}/../bin/${CMAKE_SHARED_LIBRARY_PREFIX}${SDL_LIBNAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) INSTALL(CODE @@ -1604,7 +1618,7 @@ MACRO(SD_INSTALL_DIRECTORIES) ENDFOREACH() ENDFOREACH()") - ELSE(WIN32) + ELSE(MSVC) INSTALL(CODE "FILE(READ ${CMAKE_BINARY_DIR}/xmlversion_loc.txt XMLVERSION_EXE) @@ -1636,7 +1650,7 @@ MACRO(SD_INSTALL_DIRECTORIES) ENDFOREACH() ENDFOREACH()") - ENDIF(WIN32) + ENDIF(MSVC) ENDIF(IS_USER) @@ -1668,9 +1682,7 @@ ENDIF(IN_SOURCETREE) # Generate clobber.sh/bat shell script (remove _any_ build system generated file) MACRO(SD_GENERATE_CLOBBER_SCRIPT) - IF(IN_SOURCETREE) - - IF(WIN32) + IF(MSVC) SET(TGT_SCRIPT "${SOURCE_DIR}/clobber.bat") FILE(WRITE "${TGT_SCRIPT}" "@echo off\n") @@ -1727,7 +1739,7 @@ MACRO(SD_GENERATE_CLOBBER_SCRIPT) FILE(APPEND "${TGT_SCRIPT}" "\n") FILE(APPEND "${TGT_SCRIPT}" ":END\n") - ELSE(WIN32) + ELSE(MSVC) SET(TGT_SCRIPT "${SOURCE_DIR}/clobber.sh") FILE(WRITE "${TGT_SCRIPT}" "#!/bin/sh\n") @@ -1768,10 +1780,8 @@ MACRO(SD_GENERATE_CLOBBER_SCRIPT) FILE(APPEND "${TGT_SCRIPT}" " echo \"Bad current dir for that ; please run from the root folder of a CMake-enabled SD source tree.\"\n") FILE(APPEND "${TGT_SCRIPT}" "fi\n") EXECUTE_PROCESS(COMMAND chmod ugo+x ${TGT_SCRIPT}) - ENDIF(WIN32) + ENDIF(MSVC) - ENDIF(IN_SOURCETREE) - ENDMACRO(SD_GENERATE_CLOBBER_SCRIPT) # Add non-default compile options. diff --git a/src/drivers/human/human.cpp b/src/drivers/human/human.cpp index 221ad2f9f..ee9cf9a29 100644 --- a/src/drivers/human/human.cpp +++ b/src/drivers/human/human.cpp @@ -37,8 +37,8 @@ #include #include -#include #include +#include #include //Rt* #include #include diff --git a/src/libs/ephemeris/CMakeLists.txt b/src/libs/ephemeris/CMakeLists.txt index 71961977e..00d5cdf44 100644 --- a/src/libs/ephemeris/CMakeLists.txt +++ b/src/libs/ephemeris/CMakeLists.txt @@ -15,13 +15,17 @@ ADD_PLIB_INCLUDEDIR() ADD_SDL_INCLUDEDIR() IF(WIN32) + # What for ? Comment please ! + ADD_DEFINITIONS(-DNOMINMAX) + # DLL export stuff under Windows (to avoid .def file) ADD_DEFINITIONS(-DEPHEMERIS_DLL) - ADD_DEFINITIONS(-DNOMINMAX) +ENDIF(WIN32) +IF(MSVC) # Ignore some run-time libs to avoid link time warnings and sometimes even crashes. SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt.lib") -ENDIF(WIN32) +ENDIF(MSVC) # Disable developer warning IF (COMMAND CMAKE_POLICY) @@ -31,7 +35,7 @@ ENDIF(COMMAND CMAKE_POLICY) ADD_LIBRARY(ephemeris SHARED ${EPHEMERIS_SOURCES}) # Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose) -#SET_TARGET_PROPERTIES(raceengine PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0) +#SET_TARGET_PROPERTIES(ephemeris PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0) ADD_PLIB_LIBRARY(ephemeris ul sg) diff --git a/src/libs/metar/CMakeLists.txt b/src/libs/metar/CMakeLists.txt index cd128d790..820524a15 100644 --- a/src/libs/metar/CMakeLists.txt +++ b/src/libs/metar/CMakeLists.txt @@ -9,7 +9,7 @@ SET(METAR_SOURCES mchannel.cpp msocket.cpp mexception.cpp mmetar.cpp ADD_SDLIB_INCLUDEDIR(portability math) # Disable developer warning -IF (COMMAND CMAKE_POLICY) +IF(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 NEW) ENDIF(COMMAND CMAKE_POLICY) @@ -21,9 +21,10 @@ ENDIF(WIN32) ADD_LIBRARY(metar SHARED ${METAR_SOURCES}) # Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose) -#SET_TARGET_PROPERTIES(learning PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0) +#SET_TARGET_PROPERTIES(metar PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0) -ADD_PLIB_LIBRARY(metar) +# This line does nothing : what it really intended ? +#ADD_PLIB_LIBRARY(metar) IF(WIN32) SD_INSTALL_FILES(BIN TARGETS metar) diff --git a/src/libs/portability/portability.h b/src/libs/portability/portability.h index 4767a788b..5b02108ac 100644 --- a/src/libs/portability/portability.h +++ b/src/libs/portability/portability.h @@ -23,6 +23,9 @@ #include #include +#define _USE_MATH_DEFINES +#include + #ifdef _MSC_VER #include #include @@ -41,9 +44,18 @@ #include #endif +// Missing isnan (for Apple). +#ifndef HAVE_ISNAN + +#ifndef isnan +#define isnan(x) ((x) != (x)) +#endif + +#endif + // Missing strndup, define it here (for FreeBSD). -// TODO: Move it into library. -// strndup code provided by Thierry Thomas. +// TODO: Move it into a library ! +// Code provided by Thierry Thomas. #ifndef HAVE_STRNDUP static char *strndup(const char *str, int len) @@ -61,12 +73,35 @@ static char *strndup(const char *str, int len) return ret; } -#endif +#endif // HAVE_STRNDUP + +// Missing strtok_r, define it here (for MinGW). +// TODO: Move it into a library ! +// Code provided by Charlie Gordon http://bytes.com/topic/c/answers/708293-strtok-strtok_r. +#ifndef HAVE_STRTOK_R +static char *strtok_r(char *str, const char *delim, char **nextp) +{ + char *ret; + + if (!str) + str = *nextp; + str += strspn(str, delim); + if (*str == '\0') + return 0; + ret = str; + str += strcspn(str, delim); + if (*str) + *str++ = '\0'; + *nextp = str; + return ret; +} +#endif // HAVE_STRTOK_R + // Apple platform --------------------------------------------------- #ifdef __APPLE__ -#define isnan(x) ((x) != (x)) +// Nothing special for the moment. #endif @@ -147,9 +182,12 @@ static char *strndup(const char *str, int len) #endif // _MSC_VER >= 1400 +// TODO: Remove this, now useless (see above, cmath included). // Constants from cmath / math.h // Note: Defining _USE_MATH_DEFINES before including cmath / math.h // normally defines them, but it is not very handy. +#ifndef M_PI + #define M_E 2.71828182845904523536 #define M_LOG2E 1.44269504088896340736 #define M_LOG10E 0.434294481903251827651 @@ -164,7 +202,16 @@ static char *strndup(const char *str, int len) #define M_SQRT2 1.41421356237309504880 #define M_SQRT1_2 0.707106781186547524401 +#endif + #endif // _MSC_VER +// MinGW compiler --------------------------------------------------- +#ifdef __MINGW32__ + +#define isnan(x) ((x) != (x)) + +#endif + #endif // _SD_PORTABILITY_H_ diff --git a/src/libs/raceengine/CMakeLists.txt b/src/libs/raceengine/CMakeLists.txt index 2a7dcda47..f39e51f7c 100644 --- a/src/libs/raceengine/CMakeLists.txt +++ b/src/libs/raceengine/CMakeLists.txt @@ -26,10 +26,12 @@ ADD_SDL_INCLUDEDIR() IF(WIN32) # DLL export stuff under Windows (to avoid .def file) ADD_DEFINITIONS(-DRACEENGINE_DLL) +ENDIF(WIN32) +IF(MSVC) # Ignore some run-time libs to avoid link time warnings and sometimes even crashes. SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt.lib") -ENDIF(WIN32) +ENDIF(MSVC) # Disable developer warning IF (COMMAND CMAKE_POLICY) diff --git a/src/libs/robottools/CMakeLists.txt b/src/libs/robottools/CMakeLists.txt index a7e71af55..ccc45f88d 100644 --- a/src/libs/robottools/CMakeLists.txt +++ b/src/libs/robottools/CMakeLists.txt @@ -14,10 +14,12 @@ SET(ROBOTTOOLS_SOURCES rtteammanager.cpp rttelem.cpp rttimeanalysis.cpp rttrack IF(WIN32) # DLL export stuff under Windows (to avoid .def file) ADD_DEFINITIONS(-DROBOTTOOLS_DLL) - +ENDIF(WIN32) + +IF(MSVC) # Ignore some run-time libs to avoid link time warnings and sometimes even crashes. SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt.lib") -ENDIF(WIN32) +ENDIF(MSVC) # Disable developer warning IF (COMMAND CMAKE_POLICY) diff --git a/src/libs/tgf/CMakeLists.txt b/src/libs/tgf/CMakeLists.txt index bac6d9daa..703eadc1a 100644 --- a/src/libs/tgf/CMakeLists.txt +++ b/src/libs/tgf/CMakeLists.txt @@ -22,7 +22,7 @@ ELSE(WIN32) ENDIF(WIN32) # Disable developer warning -IF (COMMAND CMAKE_POLICY) +IF(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 NEW) ENDIF(COMMAND CMAKE_POLICY) diff --git a/src/libs/tgf/params.cpp b/src/libs/tgf/params.cpp index a0628c8d5..12cbb07fc 100644 --- a/src/libs/tgf/params.cpp +++ b/src/libs/tgf/params.cpp @@ -199,11 +199,11 @@ getFullName (const char *sectionName, const char *paramName) fullName = (char *) malloc (strlen (sectionName) + strlen (paramName) + 2); if (!fullName) { -#ifdef WIN32 +#ifdef _MSC_VER GfLogError ("getFullName: malloc (%03Iu) failed", strlen (sectionName) + strlen (paramName) + 2); -#else //WIN32 +#else //_MSC_VER GfLogError ("getFullName: malloc (%zu) failed", strlen (sectionName) + strlen (paramName) + 2); -#endif //WIN32 +#endif //_MSC_VER return NULL; } sprintf (fullName, "%s/%s", sectionName, paramName); @@ -331,11 +331,11 @@ addParam (struct parmHeader *conf, struct section *section, const char *paramNam param = (struct param *) calloc (1, sizeof (struct param)); if (!param) { -#ifdef WIN32 +#ifdef _MSC_VER GfLogError ("addParam: calloc (1, %03Iu) failed\n", sizeof (struct param)); -#else //WIN32 +#else //_MSC_VER GfLogError ("addParam: calloc (1, %zu) failed\n", sizeof (struct param)); -#endif //WIN32 +#endif //_MSC_VER goto bailout; } @@ -455,11 +455,11 @@ addSection (struct parmHeader *conf, const char *sectionName) section = (struct section *) calloc (1, sizeof (struct section)); if (!section) { -#ifdef WIN32 +#ifdef _MSC_VER GfLogError ("addSection: calloc (1, 03Iu) failed\n", sizeof (struct section)); -#else //WIN32 +#else //_MSC_VER GfLogError ("addSection: calloc (1, %zu) failed\n", sizeof (struct section)); -#endif //WIN32 +#endif //_MSC_VER return NULL; } @@ -525,11 +525,11 @@ createParmHeader (const char *file) conf = (struct parmHeader *) calloc (1, sizeof (struct parmHeader)); if (!conf) { -#ifdef WIN32 +#ifdef _MSC_VER GfLogError ("gfParmReadFile: calloc (1, %03Iu) failed\n", sizeof (struct parmHeader)); -#else //WIN32 +#else //_MSC_VER GfLogError ("gfParmReadFile: calloc (1, %zu) failed\n", sizeof (struct parmHeader)); -#endif //WIN32 +#endif //_MSC_VER return NULL; } @@ -537,11 +537,11 @@ createParmHeader (const char *file) conf->rootSection = (struct section *) calloc (1, sizeof (struct section)); if (!conf->rootSection) { -#ifdef WIN32 +#ifdef _MSC_VER GfLogError ("gfParmReadFile: calloc (1, %03Iu) failed\n", sizeof (struct section)); -#else //WIN32 +#else //_MSC_VER GfLogError ("gfParmReadFile: calloc (1, %zu) failed\n", sizeof (struct section)); -#endif //WIN32 +#endif //_MSC_VER goto bailout; } GF_TAILQ_INIT (&(conf->rootSection->paramList)); @@ -1135,11 +1135,11 @@ GfParmReadBuf (char *buffer) /* Handle creation */ parmHandle = (struct parmHandle *) calloc (1, sizeof (struct parmHandle)); if (!parmHandle) { -#ifdef WIN32 +#ifdef _MSC_VER GfLogError ("GfParmReadBuf: calloc (1, %03Iu) failed\n", sizeof (struct parmHandle)); -#else //WIN32 +#else //_MSC_VER GfLogError ("GfParmReadBuf: calloc (1, %zu) failed\n", sizeof (struct parmHandle)); -#endif //WIN32 +#endif //_MSC_VER goto bailout; } @@ -1227,11 +1227,11 @@ GfParmReadFile (const char *file, int mode, bool neededFile) /* Handle creation */ parmHandle = (struct parmHandle *) calloc (1, sizeof (struct parmHandle)); if (!parmHandle) { -#ifdef WIN32 +#ifdef _MSC_VER GfLogError ("GfParmReadFile: calloc (1, %03Iu) failed\n", sizeof (struct parmHandle)); -#else //WIN32 +#else //_MSC_VER GfLogError ("GfParmReadFile: calloc (1, %zu) failed\n", sizeof (struct parmHandle)); -#endif //WIN32 +#endif //_MSC_VER goto bailout; } @@ -1723,15 +1723,15 @@ GfParmWriteFileSDHeader (const char *file, void *parmHandle, const char *name, c First = false; char time_buf[255]; -#ifdef WIN32 +#ifdef _MSC_VER _strdate_s(time_buf, sizeof(time_buf)); -#else +#else //_MSC_VER time_t rawtime; struct tm *timeinfo; time( &rawtime ); timeinfo = localtime( &rawtime ); strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %X", timeinfo); -#endif //WIN32 +#endif //_MSC_VER fputs ("