Fixed: Compilation with MFC in a custom path and/or STLport
This commit is contained in:
parent
2d91edd634
commit
57438eff01
2 changed files with 73 additions and 11 deletions
|
@ -87,26 +87,25 @@ IF(WITH_STATIC)
|
||||||
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
|
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
|
||||||
ENDIF(WITH_STATIC)
|
ENDIF(WITH_STATIC)
|
||||||
|
|
||||||
NL_SETUP_BUILD()
|
IF(WITH_MFC)
|
||||||
|
FIND_PACKAGE(CustomMFC REQUIRED)
|
||||||
|
ENDIF(WITH_MFC)
|
||||||
|
|
||||||
IF(WITH_STLPORT)
|
IF(WITH_STLPORT)
|
||||||
FIND_PACKAGE(STLport REQUIRED)
|
FIND_PACKAGE(STLport REQUIRED)
|
||||||
INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
FIND_PACKAGE(WindowsSDK REQUIRED)
|
FIND_PACKAGE(WindowsSDK REQUIRED)
|
||||||
# convert IDE fullpath to include path
|
# convert IDE fullpath to include path
|
||||||
STRING(REGEX REPLACE "Common7/IDE/.+" "VC/include" VCINCLUDE_DIR ${CMAKE_MAKE_PROGRAM})
|
STRING(REGEX REPLACE "Common7/IDE/.+" "VC/include" VC_INCLUDE_DIR ${CMAKE_MAKE_PROGRAM})
|
||||||
# use VC++ and Windows SDK include paths
|
# use VC++ and Windows SDK include paths
|
||||||
INCLUDE_DIRECTORIES(${VCINCLUDE_DIR} ${WINSDK_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR})
|
||||||
# deactivate all global include paths
|
# deactivate all global include paths
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /X")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /X")
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
ENDIF(WITH_STLPORT)
|
ENDIF(WITH_STLPORT)
|
||||||
|
|
||||||
IF(WITH_MFC)
|
NL_SETUP_BUILD()
|
||||||
FIND_PACKAGE(MFC)
|
|
||||||
ENDIF(WITH_MFC)
|
|
||||||
|
|
||||||
NL_SETUP_BUILD_FLAGS()
|
NL_SETUP_BUILD_FLAGS()
|
||||||
|
|
||||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake)
|
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake)
|
||||||
|
@ -124,7 +123,8 @@ IF(WITH_NEL)
|
||||||
FIND_PACKAGE(CppTest)
|
FIND_PACKAGE(CppTest)
|
||||||
ENDIF(WITH_NEL_TESTS)
|
ENDIF(WITH_NEL_TESTS)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include ${LIBXML2_INCLUDE_DIR})
|
||||||
|
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
|
||||||
ADD_SUBDIRECTORY(nel)
|
ADD_SUBDIRECTORY(nel)
|
||||||
ENDIF(WITH_NEL)
|
ENDIF(WITH_NEL)
|
||||||
|
|
||||||
|
|
62
code/CMakeModules/FindCustomMFC.cmake
Normal file
62
code/CMakeModules/FindCustomMFC.cmake
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
# - Locate MFC libraries
|
||||||
|
# This module defines
|
||||||
|
# MFC_FOUND, if false, do not try to link to MFC
|
||||||
|
# MFC_LIBRARY_DIR, where to find libraries
|
||||||
|
# MFC_INCLUDE_DIR, where to find headers
|
||||||
|
|
||||||
|
# Try to find MFC using official module, MFC_FOUND is set
|
||||||
|
FIND_PACKAGE(MFC)
|
||||||
|
|
||||||
|
SET(CUSTOM_MFC_DIR FALSE)
|
||||||
|
|
||||||
|
# If using STLport and MFC have been found, remember its directory
|
||||||
|
IF(WITH_STLPORT AND MFC_FOUND)
|
||||||
|
STRING(REGEX REPLACE "Common7/IDE/.+" "VC/atlmfc" MFC_STANDARD_DIR ${CMAKE_MAKE_PROGRAM})
|
||||||
|
ENDIF(WITH_STLPORT AND MFC_FOUND)
|
||||||
|
|
||||||
|
# If using STLport or MFC haven't been found, search for afxwin.h
|
||||||
|
IF(WITH_STLPORT OR NOT MFC_FOUND)
|
||||||
|
FIND_PATH(MFC_DIR
|
||||||
|
include/afxwin.h
|
||||||
|
PATHS
|
||||||
|
${MFC_STANDARD_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(CustomMFC_FIND_REQUIRED)
|
||||||
|
SET(MFC_FIND_REQUIRED TRUE)
|
||||||
|
ENDIF(CustomMFC_FIND_REQUIRED)
|
||||||
|
|
||||||
|
# Display an error message if MFC are not found, MFC_FOUND is updated
|
||||||
|
# User will be able to update MFC_DIR to the correct directory
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MFC DEFAULT_MSG MFC_DIR)
|
||||||
|
|
||||||
|
IF(MFC_FOUND)
|
||||||
|
SET(CUSTOM_MFC_DIR TRUE)
|
||||||
|
SET(MFC_INCLUDE_DIR "${MFC_DIR}/include")
|
||||||
|
INCLUDE_DIRECTORIES(${MFC_INCLUDE_DIR})
|
||||||
|
ENDIF(MFC_FOUND)
|
||||||
|
ENDIF(WITH_STLPORT OR NOT MFC_FOUND)
|
||||||
|
|
||||||
|
# Only if using a custom path
|
||||||
|
IF(CUSTOM_MFC_DIR)
|
||||||
|
IF(NOT CMAKE_SIZEOF_VOID_P)
|
||||||
|
MESSAGE(FATAL_ERROR "Size of void* is not set, you should call PROJECT(...) before")
|
||||||
|
ENDIF(NOT CMAKE_SIZEOF_VOID_P)
|
||||||
|
|
||||||
|
# Using 32 or 64 bits libraries
|
||||||
|
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64")
|
||||||
|
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib")
|
||||||
|
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|
||||||
|
# Add MFC libraries directory to default library path
|
||||||
|
LINK_DIRECTORIES(${MFC_LIBRARY_DIR})
|
||||||
|
ENDIF(CUSTOM_MFC_DIR)
|
||||||
|
|
||||||
|
IF(MFC_FOUND)
|
||||||
|
# Set definitions for using MFC in DLL
|
||||||
|
SET(MFC_DEFINITIONS -D_AFXDLL)
|
||||||
|
ENDIF(MFC_FOUND)
|
||||||
|
|
||||||
|
# TODO: create a macro which set MFC_DEFINITIONS, MFC_LIBRARY_DIR and MFC_INCLUDE_DIR for a project
|
Loading…
Reference in a new issue