-#FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s)\r
-#FIND_LIBRARY(TINYXML_LIBRARY NAMES tinyxml tinyxml_s)\r
-FIND_LIBRARY(ZTHREADS_LIBRARY NAMES zthread ZThread zthread_s)\r
-\r
-#IF(SQLITE3_LIBRARY)\r
-# TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY})\r
-#ELSE(SQLITE3_LIBRARY)\r
-# MESSAGE(FATAL_ERROR "Could not find SQLite library. You must set the location manually.")\r
-#ENDIF(SQLITE3_LIBRARY)\r
-\r
-#IF(TINYXML_LIBRARY)\r
-# TARGET_LINK_LIBRARIES(fms ${TINYXML_LIBRARY})\r
-#ELSE(TINYXML_LIBRARY)\r
-# MESSAGE(FATAL_ERROR "Could not find TinyXML library. You must set the location manually.")\r
-#ENDIF(TINYXML_LIBRARY)\r
-\r
-IF(ZTHREADS_LIBRARY)\r
- TARGET_LINK_LIBRARIES(fms ${ZTHREADS_LIBRARY})\r
-ELSE(ZTHREADS_LIBRARY)\r
- MESSAGE(FATAL_ERROR "Could not find ZThreads library. You must set the location manually.")\r
-ENDIF(ZTHREADS_LIBRARY)\r
+# add -lxnet and -lsocket on solaris\r
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
+ TARGET_LINK_LIBRARIES(fms xnet)\r
+ TARGET_LINK_LIBRARIES(fms socket)\r
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
+\r
+IF(NOT USE_BUNDLED_SQLITE)\r
+ FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s)\r
+ENDIF(NOT USE_BUNDLED_SQLITE)\r
+FIND_LIBRARY(TINYXML_LIBRARY NAMES tinyxml tinyxml_s)\r
+FIND_LIBRARY(PTHREADS_LIBRARY NAMES pthread pthreads pthreadvc2)\r
+FIND_LIBRARY(SHTTPD_LIBRARY NAMES shttpd shttpd_s)\r
+FIND_LIBRARY(ICONV_LIBRARY NAMES iconv iconv_s libiconv libiconv_s)\r
+\r
+IF(SQLITE3_LIBRARY)\r
+ TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY})\r
+ELSE(SQLITE3_LIBRARY)\r
+ IF(NOT USE_BUNDLED_SQLITE)\r
+ MESSAGE(STATUS "Could not find system SQLite library. Will compile from included source.")\r
+ ENDIF(NOT USE_BUNDLED_SQLITE)\r
+ ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c)\r
+ TARGET_LINK_LIBRARIES(fms sqlite3)\r
+ INCLUDE_DIRECTORIES(libs/sqlite3)\r
+ENDIF(SQLITE3_LIBRARY)\r
+\r
+IF(TINYXML_LIBRARY)\r
+ TARGET_LINK_LIBRARIES(fms ${TINYXML_LIBRARY})\r
+ELSE(TINYXML_LIBRARY)\r
+ MESSAGE(STATUS "Could not find system TinyXML library. Will compile from included source.")\r
+ ADD_LIBRARY(tinyxml libs/tinyxml/tinystr.cpp libs/tinyxml/tinyxml.cpp libs/tinyxml/tinyxmlerror.cpp libs/tinyxml/tinyxmlparser.cpp)\r
+ TARGET_LINK_LIBRARIES(fms tinyxml)\r
+ INCLUDE_DIRECTORIES(libs/tinyxml)\r
+ENDIF(TINYXML_LIBRARY)\r
+\r
+IF(PTHREADS_LIBRARY)\r
+ TARGET_LINK_LIBRARIES(fms ${PTHREADS_LIBRARY})\r
+ELSE(PTHREADS_LIBRARY)\r
+ MESSAGE(FATAL ERROR "Could not find pthreads library. You must set the location manually.")\r
+ENDIF(PTHREADS_LIBRARY)\r
+\r
+IF(SHTTPD_LIBRARY)\r
+ TARGET_LINK_LIBRARIES(fms ${SHTTPD_LIBRARY})\r
+ELSE(SHTTPD_LIBRARY)\r
+ MESSAGE(STATUS "Could not find shttpd library. Will compile from included source.")\r
+ ADD_DEFINITIONS(-DEMBEDDED)\r
+ INCLUDE_DIRECTORIES(libs/shttpd/include)\r
+ IF(WIN32)\r
+ ADD_DEFINITIONS(-DNO_GUI)\r
+ SET(SHTTPD_PLATFORM_SRC libs/shttpd/compat_win32.c)\r
+ ELSE(WIN32)\r
+ SET(SHTTPD_PLATFORM_SRC libs/shttpd/compat_unix.c)\r
+ ENDIF(WIN32)\r
+ ADD_LIBRARY(shttpd ${SHTTPD_PLATFORM_SRC} libs/shttpd/auth.c libs/shttpd/cgi.c libs/shttpd/config.c libs/shttpd/io_cgi.c libs/shttpd/io_dir.c libs/shttpd/io_emb.c libs/shttpd/io_file.c libs/shttpd/io_socket.c libs/shttpd/io_ssi.c libs/shttpd/io_ssl.c libs/shttpd/log.c libs/shttpd/md5.c libs/shttpd/shttpd.c libs/shttpd/string.c)\r
+ TARGET_LINK_LIBRARIES(fms shttpd)\r
+ENDIF(SHTTPD_LIBRARY)\r
+\r
+IF(DO_CHARSET_CONVERSION)\r
+ ADD_DEFINITIONS(-DDO_CHARSET_CONVERSION)\r
+ IF(ICONV_LIBRARY)\r
+ TARGET_LINK_LIBRARIES(fms ${ICONV_LIBRARY})\r
+ ELSE(ICONV_LIBRARY)\r
+ IF(WIN32)\r
+ MESSAGE(FATAL ERROR "Could not find iconv library. You must set the location manually, or turn off charset conversion.")\r
+ ENDIF(WIN32)\r
+ ENDIF(ICONV_LIBRARY)\r
+ENDIF(DO_CHARSET_CONVERSION)\r