Csound Csound-dev Csound-tekno Search About

[Csnd-dev] stuck trying to build API project with Cmake

Date2022-03-10 00:27
FromIain Duncan
Subject[Csnd-dev] stuck trying to build API project with Cmake
Hi folks, I'm just learning Cmake here in order to build the csound6~ object for windows and M1, and I'm not sure what I'm doing wrong. I'm able to build the Max sample projects with their CMakeLists.txt files, but when I try to add csound as a dep I get errors. My file contents are below. If anyone has a working cmake for building the API on Mac, that would be lovely!

thanks
My attempt (not working):

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)

#############################################################
# MAX EXTERNAL
#############################################################

# copied from Pd version
find_package(Csound)

include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
)

# copied from Pd version
target_include_directories(${PROJECT_NAME} PRIVATE
  ${CSOUND_INCLUDE_DIRS})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)



Date2022-03-10 01:32
FromIain Duncan
SubjectRe: [Csnd-dev] stuck trying to build API project with Cmake
Well I got it building by giving up on find_package and using the below. But if anyone has suggestions on what I was doing wrong, I'm all ears. Now to try this out on Windows....

current CMakeLists.txt:

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)
set(CMAKE_VERBOSE_MAKEFILE ON)

#############################################################
# MAX EXTERNAL
#############################################################

# the below is not working on Mac for me so finding and specifying
# header and library explicitly
# find_package(Csound)

find_path(CSOUND_HEADER_PATH csound.h)
if(CSOUND_HEADER_PATH)
  MESSAGE("found csound header path: ${CSOUND_HEADER_PATH}")
else()
  MESSAGE(FATAL_ERROR "could not find csound header path")
endif()

find_library(CSOUND_LIBRARY CsoundLib64)
if(CSOUND_LIBRARY)
  MESSAGE("found csound library path: ${CSOUND_LIBRARY}")
else()
  MESSAGE(FATAL_ERROR "could not find csound library path")
endif()


include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
  "${CSOUND_HEADER_PATH}"
)

link_libraries(${CSOUND_LIBRARY})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)

On Wed, Mar 9, 2022 at 4:27 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
Hi folks, I'm just learning Cmake here in order to build the csound6~ object for windows and M1, and I'm not sure what I'm doing wrong. I'm able to build the Max sample projects with their CMakeLists.txt files, but when I try to add csound as a dep I get errors. My file contents are below. If anyone has a working cmake for building the API on Mac, that would be lovely!

thanks
My attempt (not working):

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)

#############################################################
# MAX EXTERNAL
#############################################################

# copied from Pd version
find_package(Csound)

include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
)

# copied from Pd version
target_include_directories(${PROJECT_NAME} PRIVATE
  ${CSOUND_INCLUDE_DIRS})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)



Date2022-03-10 02:10
FromIain Duncan
SubjectRe: [Csnd-dev] stuck trying to build API project with Cmake
Well, failing on Windows. Neither find_package(Csound) nor find_path(CSOUND_HEADER_PATH csound.h) are working, though I have installed csound. If anyone has suggestions for making it go on Windows, that would be great. the Cmake file is here:

thanks!

On Wed, Mar 9, 2022 at 5:32 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
Well I got it building by giving up on find_package and using the below. But if anyone has suggestions on what I was doing wrong, I'm all ears. Now to try this out on Windows....

current CMakeLists.txt:

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)
set(CMAKE_VERBOSE_MAKEFILE ON)

#############################################################
# MAX EXTERNAL
#############################################################

# the below is not working on Mac for me so finding and specifying
# header and library explicitly
# find_package(Csound)

find_path(CSOUND_HEADER_PATH csound.h)
if(CSOUND_HEADER_PATH)
  MESSAGE("found csound header path: ${CSOUND_HEADER_PATH}")
else()
  MESSAGE(FATAL_ERROR "could not find csound header path")
endif()

find_library(CSOUND_LIBRARY CsoundLib64)
if(CSOUND_LIBRARY)
  MESSAGE("found csound library path: ${CSOUND_LIBRARY}")
else()
  MESSAGE(FATAL_ERROR "could not find csound library path")
endif()


include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
  "${CSOUND_HEADER_PATH}"
)

link_libraries(${CSOUND_LIBRARY})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)

On Wed, Mar 9, 2022 at 4:27 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
Hi folks, I'm just learning Cmake here in order to build the csound6~ object for windows and M1, and I'm not sure what I'm doing wrong. I'm able to build the Max sample projects with their CMakeLists.txt files, but when I try to add csound as a dep I get errors. My file contents are below. If anyone has a working cmake for building the API on Mac, that would be lovely!

thanks
My attempt (not working):

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)

#############################################################
# MAX EXTERNAL
#############################################################

# copied from Pd version
find_package(Csound)

include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
)

# copied from Pd version
target_include_directories(${PROJECT_NAME} PRIVATE
  ${CSOUND_INCLUDE_DIRS})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)



Date2022-03-10 09:22
FromRory Walsh
SubjectRe: [Csnd-dev] stuck trying to build API project with Cmake
I think you got this sorted, but I usually do something like this:

include_directories("C:\\Program Files\\Csound6_x64\\include\\csound")
find_library(CSOUND_LIBRARY NAMES csound64 HINTS "c:\\Program Files\\Csound6_x64\\lib")

Csound on Windows has been isntalling to that directory for quite some time now, so I consider it a pretty safe bet - for Csound6 at least. 

On Thu, 10 Mar 2022 at 02:11, Iain Duncan <iainduncanlists@gmail.com> wrote:
Well, failing on Windows. Neither find_package(Csound) nor find_path(CSOUND_HEADER_PATH csound.h) are working, though I have installed csound. If anyone has suggestions for making it go on Windows, that would be great. the Cmake file is here:

thanks!

On Wed, Mar 9, 2022 at 5:32 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
Well I got it building by giving up on find_package and using the below. But if anyone has suggestions on what I was doing wrong, I'm all ears. Now to try this out on Windows....

current CMakeLists.txt:

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)
set(CMAKE_VERBOSE_MAKEFILE ON)

#############################################################
# MAX EXTERNAL
#############################################################

# the below is not working on Mac for me so finding and specifying
# header and library explicitly
# find_package(Csound)

find_path(CSOUND_HEADER_PATH csound.h)
if(CSOUND_HEADER_PATH)
  MESSAGE("found csound header path: ${CSOUND_HEADER_PATH}")
else()
  MESSAGE(FATAL_ERROR "could not find csound header path")
endif()

find_library(CSOUND_LIBRARY CsoundLib64)
if(CSOUND_LIBRARY)
  MESSAGE("found csound library path: ${CSOUND_LIBRARY}")
else()
  MESSAGE(FATAL_ERROR "could not find csound library path")
endif()


include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
  "${CSOUND_HEADER_PATH}"
)

link_libraries(${CSOUND_LIBRARY})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)

On Wed, Mar 9, 2022 at 4:27 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
Hi folks, I'm just learning Cmake here in order to build the csound6~ object for windows and M1, and I'm not sure what I'm doing wrong. I'm able to build the Max sample projects with their CMakeLists.txt files, but when I try to add csound as a dep I get errors. My file contents are below. If anyone has a working cmake for building the API on Mac, that would be lovely!

thanks
My attempt (not working):

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)

#############################################################
# MAX EXTERNAL
#############################################################

# copied from Pd version
find_package(Csound)

include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
)

# copied from Pd version
target_include_directories(${PROJECT_NAME} PRIVATE
  ${CSOUND_INCLUDE_DIRS})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)



Date2022-03-10 14:38
FromIain Duncan
SubjectRe: [Csnd-dev] stuck trying to build API project with Cmake
thanks Rory. I did get it working, but that seems a bit less hacky than what I used so I'll try that.

iain

On Thu, Mar 10, 2022 at 1:22 AM Rory Walsh <rorywalsh@ear.ie> wrote:
I think you got this sorted, but I usually do something like this:

include_directories("C:\\Program Files\\Csound6_x64\\include\\csound")
find_library(CSOUND_LIBRARY NAMES csound64 HINTS "c:\\Program Files\\Csound6_x64\\lib")

Csound on Windows has been isntalling to that directory for quite some time now, so I consider it a pretty safe bet - for Csound6 at least. 

On Thu, 10 Mar 2022 at 02:11, Iain Duncan <iainduncanlists@gmail.com> wrote:
Well, failing on Windows. Neither find_package(Csound) nor find_path(CSOUND_HEADER_PATH csound.h) are working, though I have installed csound. If anyone has suggestions for making it go on Windows, that would be great. the Cmake file is here:

thanks!

On Wed, Mar 9, 2022 at 5:32 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
Well I got it building by giving up on find_package and using the below. But if anyone has suggestions on what I was doing wrong, I'm all ears. Now to try this out on Windows....

current CMakeLists.txt:

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)
set(CMAKE_VERBOSE_MAKEFILE ON)

#############################################################
# MAX EXTERNAL
#############################################################

# the below is not working on Mac for me so finding and specifying
# header and library explicitly
# find_package(Csound)

find_path(CSOUND_HEADER_PATH csound.h)
if(CSOUND_HEADER_PATH)
  MESSAGE("found csound header path: ${CSOUND_HEADER_PATH}")
else()
  MESSAGE(FATAL_ERROR "could not find csound header path")
endif()

find_library(CSOUND_LIBRARY CsoundLib64)
if(CSOUND_LIBRARY)
  MESSAGE("found csound library path: ${CSOUND_LIBRARY}")
else()
  MESSAGE(FATAL_ERROR "could not find csound library path")
endif()


include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
  "${CSOUND_HEADER_PATH}"
)

link_libraries(${CSOUND_LIBRARY})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)

On Wed, Mar 9, 2022 at 4:27 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
Hi folks, I'm just learning Cmake here in order to build the csound6~ object for windows and M1, and I'm not sure what I'm doing wrong. I'm able to build the Max sample projects with their CMakeLists.txt files, but when I try to add csound as a dep I get errors. My file contents are below. If anyone has a working cmake for building the API on Mac, that would be lovely!

thanks
My attempt (not working):

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-pretarget.cmake)

#############################################################
# MAX EXTERNAL
#############################################################

# copied from Pd version
find_package(Csound)

include_directories(
"${MAX_SDK_INCLUDES}"
"${MAX_SDK_MSP_INCLUDES}"
"${MAX_SDK_JIT_INCLUDES}"
)

# copied from Pd version
target_include_directories(${PROJECT_NAME} PRIVATE
  ${CSOUND_INCLUDE_DIRS})

file(GLOB PROJECT_SRC
     "*.h"
"*.c"
     "*.cpp"
)
add_library(
${PROJECT_NAME}
MODULE
${PROJECT_SRC}
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-sdk-base/script/max-posttarget.cmake)