cmake_minimum_required(VERSION 2.6) project(noise) cmake_policy(SET CMP0003 NEW) # project version set( ${PROJECT_NAME}_MAJOR_VERSION 1 ) set( ${PROJECT_NAME}_MINOR_VERSION 0 ) set( ${PROJECT_NAME}_PATCH_LEVEL 0 ) # set default build to Release if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE ) endif() set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") # # Configure paths # set(CONFIG_DIR_BIN bin/) set(CONFIG_DIR_ETC etc/${PROJECT_NAME}/) set(CONFIG_DIR_LIB lib/${PROJECT_NAME}/) set(CONFIG_DIR_SHARE ./) # Output paths set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib) # Set compiler specific build flags IF (UNIX) set(CMAKE_CXX_FLAGS "-msse -Wunused -Wall") set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -s") ENDIF() IF (MSVC_IDE) set(CMAKE_CXX_FLAGS "/DWIN32 /D_CONSOLE /DZLIB_WINAPI /fp:fast /EHsc") set(CMAKE_CXX_FLAGS_DEBUG "/DDEBUG /D_DEBUG /MTd /Zi") set(CMAKE_CXX_FLAGS_RELEASE "/MT") ENDIF (MSVC_IDE) # # sources # set(noise_source src/model/cylinder.cpp src/model/line.cpp src/model/plane.cpp src/model/sphere.cpp src/module/abs.cpp src/module/add.cpp src/module/billow.cpp src/module/blend.cpp src/module/cache.cpp src/module/checkerboard.cpp src/module/clamp.cpp src/module/const.cpp src/module/curve.cpp src/module/cylinders.cpp src/module/displace.cpp src/module/exponent.cpp src/module/invert.cpp src/module/max.cpp src/module/min.cpp src/module/modulebase.cpp src/module/multiply.cpp src/module/perlin.cpp src/module/power.cpp src/module/ridgedmulti.cpp src/module/rotatepoint.cpp src/module/scalebias.cpp src/module/scalepoint.cpp src/module/select.cpp src/module/spheres.cpp src/module/terrace.cpp src/module/translatepoint.cpp src/module/turbulence.cpp src/module/voronoi.cpp src/latlon.cpp src/noisegen.cpp src/win32/dllmain.cpp ) source_group(${PROJECT_NAME} FILES ${noise_source}) # # project files # set(noise_configs files/banned.txt files/commands.cfg files/config.cfg files/item_alias.cfg files/ENABLED_RECIPES.cfg files/motd.txt files/permissions.txt files/roles.txt files/rules.txt files/whitelist.txt ) set(mineserver_dirs files/recipes ) include_directories(src/) # # dependencies # set(noise_depends # ZLIB # #Lua51 # Event # Noise ) # # dependency check # set(TARGET noise) message(STATUS "Dependency check: ${TARGET}") set(dependency_error False) foreach(lib ${${TARGET}_depends}) find_package(${lib}) string(TOUPPER ${lib} LIB) if (NOT ${LIB}_FOUND) set(errors "${errors}\t\t- ${lib}\n") set(dependency_error True) endif() endforeach() if (dependency_error) message(FATAL_ERROR "\n\tNot all dependencies could be found:\n${errors}\nAfter installing them please rerun cmake.\n") endif() # # platform-specific tweaks # if(WIN32) # this requires WinMain() entry, disabled until console/GUI option is added #set(exe "WIN32") # this shouldn't be here, but can cmake find these .lib's? # do we really need winmm? foreach(lib ws2_32 winmm) string(TOUPPER ${lib} LIB) list(APPEND noise_depends "${lib}") set(${LIB}_LIBRARY "${lib}") endforeach() else() if(NOISE_DIR_IS_LIBNOISE) add_definitions(-DLIBNOISE) endif() endif() # # subdirectories # #add_subdirectory(plugins) # # build targets # set(TARGET noise) message(STATUS "Target: ${TARGET}") add_library(${TARGET} SHARED ${${TARGET}_source}) target_link_libraries(${TARGET}) foreach(lib ${${TARGET}_depends}) string(TOUPPER ${lib} LIB) include_directories(${${LIB}_INCLUDE_DIR}) target_link_libraries(${TARGET} ${${LIB}_LIBRARY}) endforeach() # copy configs for local usage foreach(path ${mineserver_configs}) # make full path w/o "files/" string(REGEX REPLACE "^files/" "${EXECUTABLE_OUTPUT_PATH}/" dest "${path}") if(NOT EXISTS ${dest}) message(STATUS "Configuring: ${dest}") configure_file(${path} ${dest} COPYONLY) endif() endforeach() # # install # install(TARGETS noise RUNTIME DESTINATION ${CONFIG_DIR_BIN}/ ) #install(FILES ${mineserver_configs} # DESTINATION ${CONFIG_DIR_ETC}/ #) #install(DIRECTORY ${mineserver_dirs} # DESTINATION ${CONFIG_DIR_SHARE}/ #) # # cpack # set(CPACK_PACKAGE_VENDOR "libnoise.sourceforge.net") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A portable, open-source, coherent noise-generating library for C++") set(CPACK_PACKAGE_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_LEVEL}) set(CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_MAJOR_VERSION}) set(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_MINOR_VERSION}) set(CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_PATCH_LEVEL}) set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local") include(CPack)