2010-02-28 10:04:35 +01:00
# - Find ENET library
# Find the native ENET includes and library
# This module defines
# ENET_INCLUDE_DIR, where to find enet/enet.h
# ENET_LIBRARY libraries to link against to use ENET
# ENET_FOUND If false, do not try to use ENET
# $ENETDIR is an environment variable that would correspond
# to the prefix used to configure ENET.
#
# Created by Jean-Philippe Meuret, based on the FindOpenAL.cmake module
# modified by Bryan Donlan, from original version by Eric Wang.
FIND_PATH ( ENET_INCLUDE_DIR enet/enet.h
H I N T S E N V $ E N E T D I R
P A T H _ S U F F I X E S
H e a d e r s i n c l u d e
P A T H S
~ / L i b r a r y / F r a m e w o r k s / G L F W . f r a m e w o r k
/ L i b r a r y / F r a m e w o r k s / G L F W . f r a m e w o r k
/ S y s t e m / L i b r a r y / F r a m e w o r k s / G L F W . f r a m e w o r k # Tiger
/ u s r / l o c a l
/ u s r
/ s w # Fink
/ o p t / l o c a l # DarwinPorts
/ o p t / c s w # Blastwave
/ o p t )
# I'm not sure if I should do a special casing for Apple. It is
# unlikely that other Unix systems will find the framework path.
# But if they do ([Next|Open|GNU]Step?),
# do they want the -framework option also?
IF ( ${ ENET_INCLUDE_DIR } MATCHES ".framework" )
STRING ( REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" ENET_FRAMEWORK_PATH_TMP ${ ENET_INCLUDE_DIR } )
IF ( "${ENET_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
O R " $ { E N E T _ F R A M E W O R K _ P A T H _ T M P } " S T R E Q U A L " / S y s t e m / L i b r a r y / F r a m e w o r k s "
)
# String is in default search path, don't need to use -F
SET ( ENET_LIBRARY "-framework GLFW" CACHE STRING "GLFW framework for OSX" )
ELSE ( "${ENET_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
O R " $ { E N E T _ F R A M E W O R K _ P A T H _ T M P } " S T R E Q U A L " / S y s t e m / L i b r a r y / F r a m e w o r k s "
)
# String is not /Library/Frameworks, need to use -F
SET ( ENET_LIBRARY "-F${ENET_FRAMEWORK_PATH_TMP} -framework GLFW" CACHE STRING "GLFW framework for OSX" )
ENDIF ( "${ENET_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
O R " $ { E N E T _ F R A M E W O R K _ P A T H _ T M P } " S T R E Q U A L " / S y s t e m / L i b r a r y / F r a m e w o r k s "
)
# Clear the temp variable so nobody can see it
SET ( ENET_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "" )
ELSE ( ${ ENET_INCLUDE_DIR } MATCHES ".framework" )
FIND_LIBRARY ( ENET_LIBRARY
N A M E S e n e t
H I N T S E N V E N E T D I R
P A T H _ S U F F I X E S l i b 6 4 l i b l i b s 6 4 l i b s l i b s / W i n 3 2 l i b s / W i n 6 4
P A T H S
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t )
ENDIF ( ${ ENET_INCLUDE_DIR } MATCHES ".framework" )
SET ( ENET_FOUND "NO" )
IF ( ENET_LIBRARY )
2010-04-16 12:03:16 +02:00
#If ENET_INCLUDE_DIR points to /usr/include/enet while enet.h is in /usr/include/enet/enet.h,
#then #include <time.h> will cause /usr/include/enet/time.h be loaded instead of /usr/include/time.h, which causes compiler errors.
#We warn the user if the wrong include is possibly used
IF ( NOT EXISTS "${ENET_INCLUDE_DIR}/enet/enet.h" )
MESSAGE ( WARNING " The file ${ENET_INCLUDE_DIR}/enet/enet.h does not exists. Make sure ENET_INCLUDE_DIR points to the directory containing \" enet/enet.h\ " and not to the directory containing \" enet.h\ ". ENET_INCLUDE_DIR currently has value \" ${ ENET_INCLUDE_DIR } \"")
ENDIF ( NOT EXISTS "${ENET_INCLUDE_DIR}/enet/enet.h" )
2010-02-28 10:04:35 +01:00
SET ( ENET_FOUND "YES" )
#MESSAGE(STATUS "Found ENET: ${ENET_LIBRARY}")
ENDIF ( ENET_LIBRARY )
2010-04-16 12:03:16 +02:00
#MARK_AS_ADVANCED(ENET_INCLUDE_DIR ENET_LIBRARY)