diff --git a/CMakeLists.txt b/CMakeLists.txt index b16c704..a878869 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,6 @@ endif() SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithDebInfo" "MinSizeRel") message("Build type: " ${CMAKE_BUILD_TYPE}) -## TODO, compiler dependent? set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_STK_DEBUG_ -D__RTAUDIO_DEBUG__ -D__RTMIDI_DEBUG__") @@ -19,10 +18,10 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) set(CMAKE_CXX_FLAGS "-Wall") endif() -# option(BUILD_SHARED "Whether to build the shared library" OFF) -# option(BUILD_STATIC "Whether to build the static library" ON) +option(BUILD_SHARED "Whether to build the shared library" ON) +option(BUILD_STATIC "Whether to build the static library" ON) option(REALTIME "Realtime support" ON) -# option(ENABLE_JACK "Enable JACK" ON) +option(ENABLE_JACK "Enable JACK" ON) option(ENABLE_ALSA "Enable ALSA API support (linux only)" ON) # option(ENABLE_OSS "Enable OSS API Support (unixes only)" ON) option(ENABLE_ASIO "Enable ASIO API support (windows only)" OFF) @@ -34,8 +33,6 @@ option(COMPILE_PROJECTS "Compile all the example projects" ON) include_directories("./include") file(GLOB STK_SRC "./src/*.cpp") # GLOB instead of GLOB_RECURSE as the asio depends on system -add_library(stk STATIC ${STK_SRC} ) - #========================================# #========== Realtime Support ============# #========================================# @@ -55,8 +52,7 @@ if(REALTIME) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) - target_link_libraries(stk PUBLIC Threads::Threads) - + link_libraries(Threads::Threads) if(${CMAKE_SYSTEM_NAME} STREQUAL Linux) # TODO: Finish Linux configuration, include different audio API supports #============== LINUX ================# @@ -65,8 +61,8 @@ if(REALTIME) find_package(ALSA REQUIRED) if(ALSA_FOUND) include_directories(${ALSA_INCLUDE_DIRS}) - target_link_libraries(stk PUBLIC ${ALSA_LIBRARIES}) - target_compile_definitions(stk PUBLIC __LINUX_ALSA__) + link_libraries(${ALSA_LIBRARIES}) + add_definitions(__LINUX_ALSA__) endif() endif() elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) @@ -74,36 +70,36 @@ if(REALTIME) message("Machintosh DETECTED!") find_package(CoreAudio REQUIRED) include_directories(${COREAUDIO_INCLUDE_DIRS}) - target_compile_definitions(stk PUBLIC -D__MACOSX_CORE__) - target_link_libraries(stk PUBLIC ${COREAUDIO_LIBRARY} ${COREAUDIO_FOUNDATION} ${COREAUDIO_MIDI}) + add_definitions(-D__MACOSX_CORE__) + link_libraries(${COREAUDIO_LIBRARY} ${COREAUDIO_FOUNDATION} ${COREAUDIO_MIDI}) elseif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) # TODO: MORE SUPPORT (e.g., MSYS)? # Tested under MSYS2 with Mingw64 toolchain #============== WINDOWS ================# message("Windows DETECTED!") - target_link_libraries(stk PUBLIC winmm ole32 wsock32) - target_compile_definitions(stk PUBLIC -D__WINDOWS_MM__) + link_libraries(winmm ole32 wsock32) + add_definitions(-D__WINDOWS_MM__) # TODO: ASIO NOT WORKING YET if(ENABLE_ASIO) message("ENALBING ASIO") include_directories("./src/include") - target_sources(stk PUBLIC "${CMAKE_SOURCE_DIR}/src/include/asio.cpp" "${CMAKE_SOURCE_DIR}/src/include/asiodrivers.cpp" - "${CMAKE_SOURCE_DIR}/src/include/asiolist.cpp" "${CMAKE_SOURCE_DIR}/src/include/iasiothiscallresolver.cpp") - target_compile_definitions(stk PUBLIC -D__WINDOWS_ASIO__) + # target_sources(stk PUBLIC "${CMAKE_SOURCE_DIR}/src/include/asio.cpp" "${CMAKE_SOURCE_DIR}/src/include/asiodrivers.cpp" + # "${CMAKE_SOURCE_DIR}/src/include/asiolist.cpp" "${CMAKE_SOURCE_DIR}/src/include/iasiothiscallresolver.cpp") + add_definitions(-D__WINDOWS_ASIO__) endif() if(ENABLE_WASAPI) message("ENALBING WASAPI") - target_link_libraries(stk PUBLIC mfuuid mfplat wmcodecdspuuid ksuser) - target_compile_definitions(stk PUBLIC -D__WINDOWS_WASAPI__) + link_libraries(mfuuid mfplat wmcodecdspuuid ksuser) + add_definitions(-D__WINDOWS_WASAPI__) endif() if(ENABLE_DS) message("ENALBING Directsound") - target_link_libraries(stk PUBLIC dsound) - target_compile_definitions(stk PUBLIC -D__WINDOWS_DS__) + link_libraries(dsound) + add_definitions(-D__WINDOWS_DS__) endif() else() message("CMAKE_SYSTEM_NAME:" ${CMAKE_SYSTEM_NAME}) @@ -114,14 +110,26 @@ endif() include(TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) if(NOT IS_BIG_ENDIAN) - target_compile_definitions(stk PUBLIC __LITTLE_ENDIAN__) + add_definitions(-D__LITTLE_ENDIAN__) endif() -# if(CMAKE_CXX_BYTE_ORDER STREQUAL LITTLE_ENDIAN) -# target_compile_definitions(stk PUBLIC __LITTLE_ENDIAN__) -# endif() +#========================================# +#========== Build the Library ===========# +#========================================# +if(BUILD_STATIC) + add_library(stk STATIC ${STK_SRC} ) +endif() + +if(BUILD_SHARED) + add_library(stk_SHARED SHARED ${STK_SRC}) + set_target_properties(stk_SHARED PROPERTIES OUTPUT_NAME stk) # rename the shared library name +endif() + +#========================================# +#========= Build the examples ===========# +#========================================# if(COMPILE_PROJECTS) - message("COMPILE PROJECTS") + message("COMPILE PROJECTS!") add_subdirectory(projects/examples) add_subdirectory(projects/eguitar) add_subdirectory(projects/demo)